14

I'm making a platformer, so when the player is facing the opposite direction, I just want to mirror the graphics. I've set up a whole Skeleton2D with Bones, then set up InverseKinematics to help animate it.

The problem is that I can't find a way to make the thing work when mirrored. Scaling the target IK doesn't work. Multiplying the IK position by -1 also doesn't work properly. It does change the target bone rotation, but the bone rotates in the reverse direction (it "pushes" the bone away).

The closest I got to get it to work properly is by applying a negative scale to the affected bone after scaling the skeleton to -1, but even then, the image flips back to the right side.

Right now, I'm starting to think I'll have to use the IKs to create the animations only as the means to key the bone positions, as I can't figure out a way to make a flipped animation with IK targets. So, once all bones are keyed into the animations, I can safely delete the IKs

To reproduce:

  • Make a Skeleton2D node, make 3 children Bone2D nodes, one being the parent of the other (B1 -> B2 -> B3)
  • Create a Node2D to use as IK target
  • On the Skeleton2D Inspector, add a new SkeletonModification and enable it
  • Add a new Element to the SkeletonModification, of type TwoBoneIK (third option, from the bottom up)
  • Joint Bone One = B2 (uppermost bone); Joint Bone Two = B3 (farthest most); Target = IK_Target
  • Move the target around to see if it's working properly.
  • Attempt to mirror it in a way that it doesn't break

TLDR - How do I horizontally flip a skeleton2D with IK without breaking the animations?

top 1 comments
sorted by: hot top controversial new old
[-] jwlgowi 2 points 1 year ago

I think your supposition about using ik just to capture (key) animations is right. I wouldn’t delete the bones after because you might add or tweak the animations later.

Then you should be able to -X the scale for whatever the root node 2d of your character is.

Maybe helpful: https://ask.godotengine.org/110222/possible-animation-player-deals-animating-position-rotation

this post was submitted on 30 Aug 2023
14 points (100.0% liked)

Godot

5972 readers
145 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS