Question by
humanflag · Aug 22, 2015 at 03:42 PM ·
movement scriptstop
Can anyone help me with a simple JS wait problem
I´m trying to stop the movement of an object at its starting and end points The object ping-pongs from A to B
This is the code I´m using. this code is not mine btw
var pointB : Vector3;
function Start () { var pointA = transform.position; while (true) { yield MoveObject(transform, pointA, pointB, 3.0); yield MoveObject(transform, pointB, pointA, 3.0); } }
function MoveObject
(thisTransform : Transform, startPos : Vector3, endPos : Vector3, time : float)
{
var i = 0.0; var rate = 1.0/time;
while (i < 1.0)
{ i += Time.deltaTime * rate; thisTransform.position = Vector3.Lerp
(startPos, endPos, i); yield;
}
}
Thanks to anyone how can help me with this...
Comment
in Start, get rid of the while loop and the second yield $$anonymous$$oveObject
Your answer
Follow this Question
Related Questions
How can i make my object stop 1 Answer
I can't seem to get this movement + automatic lookat the direction of movement work for a 2.5D game 0 Answers
footstep sound and velocities / sonidos de pasos y velocidades 0 Answers
Problem with the enemy spawn,Problem with enemy 0 Answers
"} expected" and "Type or namespace definition, or end-of-file expected" Errors. Please help. 0 Answers