- Home /
How do I check for movement?
I've got an object that shoots forward and then returns to its original position. How do I check when it's reached its peak and starts to make its way back?
Answer by Eric5h5 · Jul 24, 2011 at 01:01 AM
If by "forward" you mean "up":
if (rigidbody.velocity.y < 0.0) ...
If you did mean "forward", is it bouncing off a wall? You could still check the velocity in much the same way, though.
Thanks Eric, but I've still got a problem...
I'm clamping the position of the object to a maximum x value (by "forward" I mean "right"), which means that it can still have a + or - velocity even if it's not actually moving. What I'm looking for is something like this: if (transform.position.x "is increasing") ... Of course the "is increasing" is what I need. Is there anything like that? I'm very new to program$$anonymous$$g, so forgive me if I'm not clear.
I have a similar problem and, while I have not yet succeeded, am trying to detect a change in movement over a period of fixed updates.