I have an empty GameObject that's being moved from one position to the next via Mathf.SmoothDamp. I'm trying to have the camera match its speed. This is what I have so far but I can't get the velocity readings from the rigidbody when the gravity is turned off. Empty Object script (And the object does have a rigidbody attached) Code (csharp): var howFast:Vector3; function Update() { transform.position.x = Mathf.SmoothDamp(transform.position.x,target.position.x,currentV,smoothTime,maxSpeed); transform.position.z = Mathf.SmoothDamp(transform.position.z,target.position.z,currentV,smoothTime,maxSpeed); howFast = rigidbody.velocity; } Is there a better way to get the velocity of an object or a better way to have the camera match the same speed as an object, that's not Camera.main.transform.position = target.position and also only relative to Space.World?
You can't get anything out of .velocity if you're moving an object manually. You need to apply physics forces for that (including gravity). --Eric
That's what I figured. What is the best way I can match the velocity/speed of an object and apply it to another?
Code (csharp): var pseudoVelocity = Vector3.zero; private var lastPos = Vector3.zero; function Awake(){ lastPos = transform.position; } function Update(){ pseudoVelocity = transform.position - lastPos; lastPos = transform.position; } And Bob's your uncle.