Forum rules - please read before posting.

Sprites Unity turn delay on FaceDirection action.

edited January 2015 in Technical Q&A
I have tracked this issue down rather well now I feel. I have a player with Sprites Unity animation. Thus this means animEngine.turningIsLinear is true.

If I click to move then SetLookDirection gets called once and thus a Turn(false) call also happens. MoveUpdate() comes along the next frame and sees that moveSpeed is > 0.01f and calls a Turn(true). This then gives the appearance of an extremely quick turn. In fact it may as well have even skipped the first Turn(false) call but I digress..

So we can conclude a turningIsLinear animation setting and any moveSpeed > 0.01 to instantly turn the character.

Now lets say I do a ActionCharFaceDirection action. SetLookDirection gets called and thus a Turn(false) call also happens. MoveUpdate() comes along and since the face direction action calls Halt() on the character, moveSpeed is now 0. Thus MoveUpdate() keeps calling a Turn(false). This gets called quite a few times and gives the appearance of my character facing from Left to Up and then finally to the Right.

Okay so we don't consider a face direction to be "moving". Fair enough. It seems odd that in the case of regular moving, turning to face the opposite direction is instant, yet delayed for a direct face direction action.

But hey I can at least go to the player script and set my turn speed to the desired value and remove the delay right? Wrong.

In the Turn function, if animEngine.turningIsLinear is true and it is not instant then the following function is eventually called:

newRotation = Quaternion.RotateTowards (transform.rotation, targetRotation, 5f);

The issue I have here is we limit ourselves to 5 degrees max delta per call to Quaternion.RotateTowards. This means that regardless of my turn speed set in my player/npc script, I will always be forced to be moving at a Turn Speed of 5.

This also means (oppositely) that during regular moving (clicking on nav mesh) that my turn speed value will also not matter as I will have a moveSpeed > 0.01 and thus I will turn instantly.

Is this intended behaviour?

Comments

  • The turn speed not affecting the RotateTowards is a bug, and will be fixed.

    Rotating is intended to be instant while moving 2D characters - this ensures they're always facing the same direction that they're moving.  However, you do have a "Turn before walking" option in Player/NPC Inspectors.
  • Got it. Thank you and I will be looking forward to the fix for RotateTowards.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.