playMaker

Author Topic: Itween - Constrain tween to axis?  (Read 2999 times)

markinjapan

  • Full Member
  • ***
  • Posts: 103
Itween - Constrain tween to axis?
« on: September 17, 2011, 11:13:03 AM »
Hi,

I have a cube that incrementally rotates 90 degrees whilst a key is pressed. If the key is released and the cube hasn't finished it's rotation, it rotates back to the original position.

This works fine until the rotation goes over 180 degrees. At this point itween decides that rotating in all axis is the quickest way to get back to the original position.

Is there any way to constrain the tween back to the original position only along a certain axis? And maybe in only one direction (always add or subtract to get to original number rather than shortest difference)?

Or, if someone can help me do this another way that would be great.

Thanks


markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Itween - Constrain tween to axis?
« Reply #1 on: September 17, 2011, 11:23:16 AM »
Having investigated this a bit, I've worked out that when I rotate something by 180 degrees (say Z), both X and the Y change from 0 to 180. Thats why I get the weird tween as it's tweening the other angles back to 0.

Is this a bug or something I have to account for?


markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Itween - Constrain tween to axis?
« Reply #2 on: September 17, 2011, 11:40:29 AM »
Ok, well, the 180 thing seems logical (because I'm flipping something by 180 I guess the others have to change as well). Maybe  ???

So, my fix is to use 'Set Rotation' to quickly rotate the gameobject after each 90 degree rotation. Since this is not the visual, it's parented to the visual object, I can quickly unparent, set rotation, reparent.

If your object is visual though (like a dice) then you couldn't do this :(

Hope that helps someone.