- Home /
move from one point to another
I want to move a cube from Point A to Point B then from Point B to point A this object movement from point A to Point B then from point B to A this movement cycle should repeat thought the game.cube should move from one point to another and should return back to original potion this cube movement should repeat again and again
Answer by suruz@kento · Nov 20, 2011 at 10:11 AM
1.Calculate scalar distance between point A to point B
var moveDirection: Vector3 = (B - A).normalized;
var distance: float = (B - A).magnitude;
use Mathf.PingPong(...) interpolate this distance over time
var pingpongDistance: float = distance * Mathf.PingPong(Time.time, 1);
calculate position of object
gameObject.transform.position = A + moveDirection * pingpongDistance;
Answer by DaveA · Nov 20, 2011 at 05:01 AM
how to make the movement like machine part moving continuously from one point to another and back to that point this should run repeatedly
Your answer
Follow this Question
Related Questions
Move object in front of another 1 Answer
Decrease distance between 2 objects 3 Answers
How to move an object in world with script 1 Answer
Animate an object to a new position... 1 Answer
Vector3.Lerp 1 Answer