hey all I’m trying to track the velocity of an object that doesn’t have a rigid body i found a script online in C# and it worked perfectly until it just stopped working for some reason. i didn’t edit the script at all i didn’t change the scripts location it just doesn’t work
here the script
using UnityEngine;
using System.Collections;
public class HandVelocity : MonoBehaviour {
public Vector3 currVel;
Vector3 prevPos;
void Update ()
{
// Position at frame start
prevPos = transform.position;
StartCoroutine( CalcVelocity(prevPos) );
}
IEnumerator CalcVelocity( Vector3 pos )
{
// Wait till it the end of the frame
// Velocity = DeltaPosition / DeltaTime
yield return new WaitForEndOfFrame();
currVel = (pos - transform.position) / Time.deltaTime;
Debug.Log( currVel );
}
}
normally the a vector 3 would display in the debug log but now it just says 0,0,0 when my object is moving
VERY CONFUSED
Thanks for looking AND thanks a lot if you can help.
PS sorry if i posted this in the wrong place i don’t use the forums much