diff options
Diffstat (limited to 'TransformVelocity.cs')
-rw-r--r-- | TransformVelocity.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/TransformVelocity.cs b/TransformVelocity.cs new file mode 100644 index 0000000..da843fc --- /dev/null +++ b/TransformVelocity.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +public class TransformVelocity : MonoBehaviour +{ + public Vector3 velocity; + + private Vector3 lastPosition; + + private void Start() + { + lastPosition = base.transform.position; + } + + private void FixedUpdate() + { + velocity = base.transform.position - lastPosition; + lastPosition = base.transform.position; + } +} |