本文整理汇总了C#中UnityEngine.Rigidbody.MovePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Rigidbody.MovePosition方法的具体用法?C# Rigidbody.MovePosition怎么用?C# Rigidbody.MovePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Rigidbody
的用法示例。
在下文中一共展示了Rigidbody.MovePosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pullObject
private IEnumerator pullObject(Rigidbody collidedRigidbody)
{
while(Vector3.Distance(transform.parent.position, collidedRigidbody.transform.position) > 1.5f)
{
pullTimer -= Time.deltaTime;
if(pullTimer < 0)
{
yield return new WaitForSeconds(0.333f);
pullTimer = resetPullTimer;
}
else
{
collidedRigidbody.MovePosition(collidedRigidbody.transform.position + Vector3.up * pullSpeed * Time.deltaTime);
yield return null;
}
}
//reach top now make fall
if (collidedRigidbody.gameObject.tag != "Player")
{
collidedRigidbody.AddForce(Vector3.right * 10, ForceMode.Impulse);
}
// else
// {
// //atTop = true;
// }
}
示例2: Start
void Start ()
{
rb3d = GetComponent<Rigidbody> ();
//Set startup position
rb3d.MovePosition(new Vector3(0.0f, playerAboveLevel, 0.0f));
}
示例3: Grab
void Grab(Rigidbody rb)
{
rb.isKinematic = false;
isGrapped = true;
rb.MovePosition(hand.transform.position);
rb.velocity = Vector3.zero;
hj.connectedBody = rb;
rb.GetComponent<Item>().checkIfKaverit();
}
示例4: Start
void Start()
{
Vector3 tangent = Vector3.zero;
int kn = 0;
rb = GetComponent<Rigidbody>();
Vector3 p = transform.position;
Vector3 np = path.FindNearestPointWorld(p, 5, ref kn, ref tangent, ref alpha);
rb.MovePosition(np);
}
示例5: Awake
private void Awake()
{
_transform = transform;
_rigidbody = GetComponent<Rigidbody>();
this.UpdateAsObservable()
.Select(_ => new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")))
.Subscribe(axis =>
{
Vector3 currentPos = _transform.position;
currentPos += axis * Time.smoothDeltaTime * speed;
_rigidbody.MovePosition(currentPos);
});
}
示例6: Update
void Update()
{
Vector3 temp = transform.position;
temp.y = 0f;
transform.position = temp;
screenPos = Camera.main.WorldToScreenPoint(transform.position);
foreach (multi.MultiplayerHandler.PlayerData data in clientServer.multiplayerHandler.playerDB) {
if (data.name == name) {
body = gameObject.GetComponent<Rigidbody> ();
body.MovePosition (new Vector3 ((float)data.posX, (float)data.posY, (float)data.posZ));
//body.MoveRotation (new Quaternion (0f, (float)clientServer.multiplayerHandler.recD, 0f, 0f));
Quaternion rot = new Quaternion ();
rot.eulerAngles = new Vector3 (0, (float)data.angleY, 0);
gameObject.transform.rotation = rot;
gameObject.GetComponent<Animator> ().SetBool ("IsWalking", data.IsWalking);
gameObject.GetComponentInChildren<GunAnimation> ().isShooting = data.IsShooting; }
}
}
示例7: Start
// Use this for initialization
void Start()
{
RigidPlayer = GetComponent<Rigidbody>();
RigidPlayer.MovePosition (Middle.transform.position);
pos = 2;
}
示例8: Receive
// void Receive(Transform warpee)
// {
// float yPosition = warpee.position.y;
//// warpee.position = new Vector3(transform.position.x, yPosition, transform.position.z);
//// warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
//
//
//
//// warpee.GetComponent<NavMeshAgent>().ResetPath();
//// warpee.position = new Vector3(spawn.position.x, yPosition, spawn.position.z);
// warpee.GetComponent<NavMeshAgent>().Warp(new Vector3(spawn.position.x, yPosition, spawn.position.z));
// }
//
// void Send(Transform warpee)
// {
// destination.Receive(warpee);
// }
void Receive(Rigidbody body)
{
float yPosition = body.position.y;
body.position = new Vector3(transform.position.x, yPosition, transform.position.z);
body.MovePosition(new Vector3(spawn.position.x, yPosition, spawn.position.z));
}
示例9: Update
void Update() {
if(nIdentity == null) return;
if (doubleScore == true) {
doubleScoreTime -= Time.deltaTime;
if (doubleScoreTime <= 0)
{
doubleScore = false;
doubleScoreTime = doubleScoreTimeInit;
}
}
if (fasterFire == true) {
fasterFireTime -= Time.deltaTime;
if (fasterFireTime <= 0)
{
fasterFire = false;
fasterFireTime = fasterFireTimeInit; //Resets timer
currentFireRate = fireRate; //Resets fire rate to classic fire rate. Only needed for local-viewing
}
}
if (shielded == true) {
shieldedTime -= Time.deltaTime;
if (shieldedTime <= 0) {
shielded = false;
shield.SetActive(false);
Destroy(shield);
shieldedTime = fasterFireTimeInit; //Resets timer
}
}
if (!nIdentity.isLocalPlayer) return;
rb = GetComponent<Rigidbody>();
Vector3 forward = transform.forward;
Vector3 right = transform.right;
#if UNITY_ANDROID
float aimH = CrossPlatformInputManager.GetAxis ("AimH");
float aimV = CrossPlatformInputManager.GetAxis ("AimV");
float moveV = CrossPlatformInputManager.GetAxis("MoveV");
float moveH = CrossPlatformInputManager.GetAxis("MoveH");
#endif
#if UNITY_STANDALONE
float aimH = (-(Input.GetKey("left") ? 1 : 0) + (Input.GetKey("right") ? 1 : 0));
float aimV = ((Input.GetKey("up") ? 1 : 0) - (Input.GetKey("down") ? 1 : 0));
float moveV = ((Input.GetKey("w") ? 1 : 0) - (Input.GetKey("s") ? 1 : 0));
float moveH = (-(Input.GetKey("a") ? 1 : 0) + (Input.GetKey("d") ? 1 : 0));
#endif
lastMoveH = moveH;
lastMoveV = moveV;
if (needsReflection && invertControls) {
Vector3 refMove = reflectPoint(moveH, moveV);
Vector3 refAim = reflectPoint(aimH, aimV);
moveH = refMove[0];
moveV = refMove[1];
aimH = refAim[0];
aimV = refAim[1];
}
float forwardSpeed = speed * moveV;
float strafeSpeed = speed * moveH;
Vector3 moveDir = forwardSpeed * forward + strafeSpeed * right;
Vector3 turretDirection = ((forward * aimV) + (right * aimH)).normalized;
rotateObject(turret, turretDirection);
Vector3 worldPos = obsCamera.position + obsCamera.parent.transform.position;
Vector3 newLocation = transform.position + moveDir * Time.deltaTime * 5;
float distPlanetToCam = Vector3.Distance(planetCenter, worldPos);
float distPlayerToCam = Vector3.Distance(newLocation, worldPos);
rotateObject(model, moveDir.normalized);
rb.MovePosition(newLocation);
}