Answer the question
In order to leave comments, you need to log in
How to move an object to a certain point using rigidbody.velocity?
I have an object that moves with the help of velocity in X and Y.
When you press the button, it should move to a certain Z coordinate.
Here is the code just moves it along the Z coordinate
rigidbody3D = GetComponent<Rigidbody>();
...
rigidbody3D.velocity = new Vector3(rigidbody3D.velocity.x, rigidbody3D.velocity.y, layerLevelPosition[1].z);
transform.position = Vector3.MoveTowards(transform.position, new Vector3(transform.position.x, transform.position.y, layerLevelPosition[1].z),0.5f);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question