- Home /
how to move object different positions in time
Hello, I have a question about moving object to different positions.
I have an object that rotates in clockwise and I want to change this rotation every 3 seconds or every spesific position.
I'm using transform.RotateAround(scoreZone.transform.position, Vector3.forward, speed * Time.deltaTime);
for rotating arround. I want to make this stop every 3 seconds and rotate anti-clockwise position. How can I do that?basicly rotate different positions every 3 seconds or spesific x-z-y
Not sure how you are doing the ti$$anonymous$$g, but to reverse the rotation you can either make the axis negative (-Vector3.forward), OR negate the computed angle e.g. (-1 speed Time.deltaTime)
Well, it is just rotating arround ;D I did not implement ti$$anonymous$$g thing yet, thats why I asked it.. I want to change position every 3 seconds. I think StartCoroutine would be great for here but I'm not sure..
you can either make the axis negative (-
I did this but dunno how can i make this in time?
Answer by Glurth · Aug 11, 2018 at 03:35 PM
Here is an UNcomplied/untested/incomplete example, but it should get the idea across:
float lastFlipTime=0;
float direction =1;
Update()
{
if(Time.time > lastFlipTime + 3.0f) // here we check the current time, against our lastFlipTime.. to see if 3 seconds has elapsed. If so, we negate the direction.
{ direction *= -1;
lastFlipTime =Time.time; }
transform.RotateAround(scoreZone.transform.position, direction * Vector3.forward, speed * Time.deltaTime);
}//end Update