- Home /
Question by
theitchypotato · Jan 09 at 09:26 PM ·
c#vector3looping
How can I constantly change the position of a target when an object reaches it.
What I want to happen is : I want a moving block to go up and down each time hitting a specific set of coordinates over and over again. Right now I have this
void Update() { float step = speed * Time.deltaTime; transform.position = Vector3.MoveTowards(transform.position, targetOne.position, step);
if (Vector3.Distance(transform.position, targetOne.position) < 0.001f)
{
targetOne.position = new Vector3(transform.position.x, -1.0f, transform.position.z);
//targetOne.position *= -1.0f;
}
but after switching the coordinates of the object downward once it doesn't go back up.
Does anyone know how I could fix it?
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
C# List looping Vector3's 2 Answers
Distribute terrain in zones 3 Answers
problem Changing Scales in Script -C# 4 Answers
While loop won't stop crashing!!! 1 Answer