I noticed when I try to set the position of a rigidbody, it doesn’t change velocity.
Is there any easy way to set the position and having the game engine automatically recognize what the velocity is supposed to be?
I noticed when I try to set the position of a rigidbody, it doesn’t change velocity.
Is there any easy way to set the position and having the game engine automatically recognize what the velocity is supposed to be?
Unity can’t assume with what velocity you want to go because it depends on how much time you want the object to take for it to go from point A to B. But theres a really simple method of moving a object to a point with a desired velocity :
var destintationPoint : Transform; //place you wanna go
var speed : float; //speed with which you wanna go
function Update () {
transform.position = Vector3.Lerp(transform.position, destinationPoint.position, Time.time * speed);
//or you can use substitute Lerp with MoveTowards for a more uniform velocity
}
I Hope this helps.