Hi people! Hope your doing great!
I'm trying to finish the movement of my game hero (a cat) and I'm facing some issues related to the script x animation. I'm doing the "flip" when user presses right/left key using scale, which is working, however, I also have some attributes rotation and position attributes being modified by the animation player. Then, when I play the game, the rotation of the hero is not properly affected by the flip and the animation has different results if the hero is facing right or left, like you can see below:

Pay attention on the rotation of the hero body when he's falling down after jumping.

Here's the flip script when users press left or right:

Here's the node tree of the cat:

Here's the attributes I'm changing through the animation player when the hero is falling after jumping:

Any clue about that?

ps. I tryied to added another parent node to hold the Entity node, applying the scale to that new parent to not affect the animation on the Entity node, but the result was the same.

  • JusTiCe8 replied to this.
  • JusTiCe8 bingo!
    I found an article about other ways to flip and this simple line solved the problem: transform.x.x = direction
    Thank you for the hint!

    fabianom Nice character 🙂 I'll looking forward to your game progress, did you know "Nine Lives" ? A platform game on Amiga at least featuring also a cat, never played with it, yet.

    Regarding your issue, I don't think there is any actual issue, strictly speaking, because rotation angle as no reason to be mirrored as well, using "scale" to do the mirroring may be a too easy shortcut. I can only advise you to provide mirrored parts or use a more robust transform. You may take a look at official platformer demo and GDQuest tutorials.

      JusTiCe8 Thanks for the support 🙂
      Well, I just checked the player code from the official platform demo on GDQuest tutorials as you said, and I found the same scale trick to change the player direction: sprite.scale.x = direction.x.
      Anyway, I will try to figure out better ways to flip using proper transforms and I let you know about the results.

      Again, thank you.

      JusTiCe8 bingo!
      I found an article about other ways to flip and this simple line solved the problem: transform.x.x = direction
      Thank you for the hint!