- Home /
Move different objects from point A to B with objects having different time to move b/w these points.
Ok, more details. Got 5 gameObjects. Object 1 will take 1sec to move from point A to point B. Object 2 will take 5 secs to move from point A to B, Object 3 will take 10 and it goes on by the multiple of 5. can any body please help to get these objects move from point A to point B in accordance with time. Currently I've only given:-
transform.position.x++;
Stops at point B. Do know how to move it with time. Can someone please help me?
Answer by goo-muffin · Jul 13, 2012 at 12:19 PM
u have to make a calculation where the time and the way has to be in it because if the way is longer it has to move faster. So use something like (only like):
var time :float = 5;
var pointA :Transform; //startpoint
var pointB :Transform; //endpoint
transform.position.y /or x or z/ += (pointA.transform.position.y - pointB.transform.position.y) / time
I think that should also have a * Time.deltaTime at the end right?
thanx for the answers, was unable to login. lemme check and will roll back.
goo-muffin , I am afraid its not making any difference. Anyway thanks for the help!
jo sorry try out with the Time.deltaTime what whydoidoit said
Your answer
![](https://koobas.hobune.stream/wayback/20220613074128im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Execute code for a certain amount of time 1 Answer
Pause button 2 Answers
Vector3.Lerp doesn't work 3 Answers
Realtime Clock? (needles) 1 Answer
Im trying to get my character to respawn after reaching a certain y axis 1 Answer