playMaker

Author Topic: Gimbal Lock and iTween Rotations [SOLVED]  (Read 4682 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 82
    • Acornbringer.com
Gimbal Lock and iTween Rotations [SOLVED]
« on: November 12, 2024, 02:06:55 PM »

I ran into this issue using iTween rotation to rotate one object to the vector 3 rotation of another object. Rather than the expected behavior of rotating straight to the target, the iTween animation takes an unusual path towards it's destination. I also noticed that this only happens when the target rotation is greater than 90 or less than -90 degrees.

Any help would be appreciated!
« Last Edit: November 16, 2024, 01:47:46 PM by acornbringer »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Gimbal Lock and iTween Rotations
« Reply #1 on: November 16, 2024, 04:04:22 AM »
Hi,

Nice Game, nice fsms organisation, well done!

Try to store the rotation of your target as "global", not local.

Make a new project for testing, have one cube as the tree, one cube as the target, work out how to tween between the two, once you master, reproduce in your game project.

the less you mess around in your project, the better, work it out outside, master it and then apply it back. this will save you lots of potential wrong fsm editing or messing with your game... you don't want that at this point in your production.

Let me know how it goes. I am going to try myself today and if I find something odd, I'll share it back with you here.


Bye,

Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Gimbal Lock and iTween Rotations
« Reply #2 on: November 16, 2024, 04:40:27 AM »
Hi,

Made a quick test and all is good, you can really trim a lot of thing from your setup, don't get position and rotation, simply use the gameobject as the target and only work it out when necessary to avoid memory assignment on trees that may never be cut.


so with just two actions, you can get the result you want.





acornbringer

  • Junior Playmaker
  • **
  • Posts: 82
    • Acornbringer.com
Re: Gimbal Lock and iTween Rotations
« Reply #3 on: November 16, 2024, 01:46:25 PM »
[...] don't get position and rotation, simply use the gameobject as the target and only work it out when necessary to avoid memory assignment on trees that may never be cut.

[...]

Good point! I have a feeling there's a lot I could be doing to optimize this project.

I recreated what you showed in a new project and oddly enough still had the bad rotation. I played around a bit more and noticed that rotating on or around the X axis is causing the gimble lock. Using the Z axis instead gave me the desired result.

When I make prefabs, I normally use the local Z to point forward meaning this particular asset would use the X axis to rotate forward like it does, causing the issue. I should be able to fix this in my game now but it's still a mystery to me how these rotations work.

Really appreciate you helping me work this out. Thanks a lot!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15620
  • Official Playmaker Support
Re: Gimbal Lock and iTween Rotations [SOLVED]
« Reply #4 on: November 17, 2024, 03:23:56 AM »
Hi,

Could not make my system bug, I tried many different weird angles for the target.

 I have attached the scene ( U2022), mess with it, if you can make it bug, let me know.

Bye,

Jean