Set flipbook on mouse click (location-relative)

Hey guys, I finally figured it out :slight_smile:

First of all, a big thanks to @Polysiens for pointing out what I was doing wrong in comparing the two positions (mouse and capsule component). This time I used a Convert Mouse Location To World Space instead, to track the location of the mouse cursor.

To mirror the sprite, I had two options: Either rotate it by 180 degrees on its Z axis, or just create another sprite sheet in my pixel art software with the sprite mirrored along the Z axis and set two different flipbooks for each of the Compare Float results. I tried the former for economy reasons, but I couldn’t get it to work. The sprite kept getting turned upside down instead of turning around. I think it has to do with the fact that the scene is top down, i.e. the background is laid along the XY plain instead of the XZ one. I tried several rotation functions and axes, to no avail. So I just tried rotating the sprite with a negative scale and it worked. Here’s my solution:


This works together with a simple move to location on LMB click and a velocity check to see if the player is moving or not. Here’s the result:
copyshapekeys
Now I want to make him use the proper animation when he’s walking “away” or “towards” the screen (quotation marks since we’re talking about 2D, obviously). But that’s a different fight :slight_smile:
Thank you again, @Polysiens for your valuable help!

1 Like