Quaternion.Euler rotation only applies at the end of timeline

My timeline applies rotation to my Player (not Player Rig, but the Player Child of it).

See pictured my code from my PlayerControls script:

My timeline plays, with all rotation working as expected, then when it ends, the Quaternion.Euler rotation is applied:

An example of the rotation that I have applied using my timeline is on the 1.5 second mark, a rotation of 22.5 is applied to the z axis, resulting in the following:

Hi Sean,

Welcome to our community! :slight_smile:

Two things are important to make Rick’s idea work:

  • only the Player Rig is animated.
  • only the Player (child of Player Rig) has got the PlayerControls component attached.

Could you please check if that’s also the case in your project?


See also:

Hi Nina,

Thanks. And thanks for your quick response!

Unsure exactly what you mean by ‘only the Player Rig is animated’

Do you mean that none of the children in my Player Rig (i.e. my player) should be animated?

And when you say animated. do you mean have keys via the Timeline/Animation windows?

As my Player (Child of the Player Rig) has keys, in order to rotate it but not the rest of the rig (therefore not the Camera).

I can confirm that only the Player (Child of the Player Rig) has the PlayerControls Script attached.

Sean

Yes, that’s what I meant. :slight_smile:

If you animate, for example, the Player Ship, the animation will override the Transform of that game object. If you move the ship via code, the animation would override those values, and you would not see the expected movement in the game window.

For this reason, we have two different game object: one for the animation, one for the movement.

The keyframes in the animation must not reference the Player Ship or any of its properties such as, for example, transform.rotation.

That makes sense. Upon removing my keyframes for rotation animation, I can see the rotation via code working as expected.

Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms