hello !
how i can make my object stop when i reach in Z axis 30 for instance …
and how i can calculate the distanse that my object walks it .
transform.Translate(Vector3.forward* Time.deltaTime*speed);
hello !
how i can make my object stop when i reach in Z axis 30 for instance …
and how i can calculate the distanse that my object walks it .
transform.Translate(Vector3.forward* Time.deltaTime*speed);
(1) Calculate the distance between your current position and the stop point. Then calculate Time.dektaTime*speed.
Then say transform.Translate(Vector3.forward*Math.Min(distanceLeft,timedMotion));
(2) The distance can be found using the standard algebraic distance formula, or by subtracting the start vector from the end vector and then taking the magnitude of the resulting vector.