- Home /
Problem with a motion script
Hello everyone,
What i'm trying to do, is to make a trap for my game that works like a spinning saw. It's constantly spinning through it's z axis and I want it to go Up and down within a certain amount of time, what I tried to do is this:
function UpAndDown()
transform.position = Vector3.Lerp(up_transform.position, down_transform.position, Time.time);
yield WaitForSeconds(1);
transform.position = Vector3.Lerp(down_transform.position, up_transform.position,Time.time);
}
The up_transform and down_transform variables contain the two transform where the saw will move within.
What I wanted to do is when the saw reached its lowest position (down_transform), wich is, after one second of movement, start going up, instead of down, but it doesn't work. At the moment it reaches the down_transform position it starts going up and down very fast, instead of returning at the same speed.
What am I doing wrong?
Thank you
Your answer
Follow this Question
Related Questions
Moving an Object to the vector of other objects on button press using a vector3 array? 0 Answers
Setting target position in Vector3.MoveTowards 2 Answers
Player isn't affected by AddForce(), Lerp() etc. 1 Answer
How do i make an object move unpredictably? 0 Answers
Moving an Object - The right way. 2D 1 Answer