mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Use GetPositionAndRotation
This commit is contained in:
parent
f8a4e1150f
commit
80f2d1e641
@ -135,8 +135,7 @@ protected virtual void Start()
|
|||||||
|
|
||||||
// Set last position and rotation to current values
|
// Set last position and rotation to current values
|
||||||
// so we can calculate velocity and angular velocity.
|
// so we can calculate velocity and angular velocity.
|
||||||
lastPosition = target.position;
|
target.GetPositionAndRotation(out lastPosition, out lastRotation);
|
||||||
lastRotation = target.rotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Update()
|
protected virtual void Update()
|
||||||
@ -145,8 +144,7 @@ protected virtual void Update()
|
|||||||
if (target == null) target = transform;
|
if (target == null) target = transform;
|
||||||
|
|
||||||
// Use global coordinates for velocity and angular velocity.
|
// Use global coordinates for velocity and angular velocity.
|
||||||
Vector3 pos = target.position;
|
target.GetPositionAndRotation(out Vector3 pos, out Quaternion rot);
|
||||||
Quaternion rot = target.rotation;
|
|
||||||
|
|
||||||
// Update velocity and angular velocity
|
// Update velocity and angular velocity
|
||||||
velocity = (pos - lastPosition) / Time.deltaTime;
|
velocity = (pos - lastPosition) / Time.deltaTime;
|
||||||
@ -412,8 +410,7 @@ public virtual void ResetState()
|
|||||||
if (target == null) target = transform;
|
if (target == null) target = transform;
|
||||||
|
|
||||||
// Reset last position and rotation
|
// Reset last position and rotation
|
||||||
lastPosition = target.position;
|
target.GetPositionAndRotation(out lastPosition, out lastRotation);
|
||||||
lastRotation = target.rotation;
|
|
||||||
|
|
||||||
// Reset velocity / angular velocity
|
// Reset velocity / angular velocity
|
||||||
velocity = Vector3.zero;
|
velocity = Vector3.zero;
|
||||||
|
Loading…
Reference in New Issue
Block a user