playMaker

Author Topic: Averaging rotations going over 360 degrees  (Read 1425 times)

troubleMaker

  • Playmaker Newbie
  • *
  • Posts: 25
Averaging rotations going over 360 degrees
« on: January 04, 2015, 07:45:26 AM »
Hi,

So my player is a ship rotating in orbit around a planet. Inside the planet i basically have an empty object, to which the ship is parented and then and i use torque velocity change to rotate the empty object.

Right now the camera is parented to the ship, but i don't want the camera to copy the movements of the ship perfectly - smooth follow is what we're talking about here - so i wanted to take the ship's parent rotations over a few frames, put them in an arrayMaker list and average them, and then set this average as the camera's parent rotation.

This works kind of ok(with some jittering issues i think i might be able to fix), but alas when the ships rotation goes over 360 and jumps back to 0 the averaging system of course gives crazy values and the camera goes wild. Any hints on how to fix this? I'm not a math wizard, i'm using playmaker after all =)




troubleMaker

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Averaging rotations going over 360 degrees
« Reply #1 on: January 11, 2015, 08:42:48 AM »
Hi,

So i managed to fix this myself by looking in to Quaternion-actions and found the slerp quaternion action that solved my problem. It does what i want quite perfectly.

Expect i have a jittering problem, which i guess comes from the fact that i'm trying to smooth follow a physics object by non-physics rotation. I use the "set rotation" action.

Now in these physics related cases people on the forums usually recommend using "fixed update" but the set rotation action doesn't have this toggle. Only "late update". I honestly don't really understand what fixed update is, but would it make sense to have that for the set rotation action?

I also found people recommending to tweak the interpolation setting for the rigidbody in question, but this didn't help me.