Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - pat

Pages: [1]
1
DOTween & DOTween Pro / Rotate a 2D rigidbody around in 90° steps
« on: June 18, 2016, 04:58:33 PM »
Dear all,
@Demigiant
 first thank you for this great tool!

Perhaps someone can help me with this.
I am trying to rotate a 2D rigidbody around in 90° steps. Every touch should rotate in 90°.

In principal it is working like this:

public void OnTap()
{
   float angle = object.Angle;
   
   angle += 90.0f;

   rb2D.DORotate (angle, 1.3f);

   if (angle == 360)
      angle = 0;
   
   object.Angle = angle;
}


This working until 270°. At 0° again, the sprite is rotating back in the other direction from 270 to 0 instead of a single step to the 360° (0°).

 I can continue to increase the angle above 360° which works, but I don't want to get to type boundaries.

 Greetings
 Pat

Pages: [1]