Ease Rotate RigidBody2D toward arbitrary angle

Posted by Plastic Sturgeon on Game Development See other posts from Game Development or by Plastic Sturgeon
Published on 2014-08-20T17:26:21Z Indexed on 2014/08/20 22:35 UTC
Read the original article Hit count: 284

Filed under:
|

I'm trying to make a rigidbody2D circle return to an orientation after a collision. But there is a weird behavior I do not expect - it always orients to the same direction.

This is what I call in FixedUpdate():

rotationdifference = -halfPI + rigidbody2D.rotation;
rigidbody2D.AddTorque (rotationdifference * ease);

I would expect this would rotate 90 degrees (1/2 Pi Radians) off of the neutral axis. But it does not. In fact it performs exactly the same as:

rotationdifference = rigidbody2D.rotation;
rigidbody2D.AddTorque (rotationdifference * ease);

What is going on? How would I be able to set an angle I want it to ease towards, and then have it ease towards it when its not colliding with some other force?

© Game Development or respective owner

Related posts about unity

Related posts about 2d-physics