I want the player to be able to break a pot when they press the spacebar. So I set up a variable on the player called “Direction” that changes to Up Down Left or Right.
Then I tried to set up some code that says, “If the Spacebar is pressed and the player is less than 20 px from the pot, play animation of the pot breaking and play animation of the character breaking the pot.”
The animation for the pot breaking works, but the character just stands there. The animation I want to play is called “LeftBreak” so with the code I wrote, if I’m facing left and pressing the spacebar, shouldn’t it work?
If the pot breaking animation works, then it’s the Player animation name that’s not correct.
First try setting the animation to Player.Direction + "Break". If that doesn’t work, use a debug log to console action to write Player.Direction + "Break" and run the game in debug mode. Check the debugger console to see the output.
If that seems fine, confirm the animation name is the correct, with the same upper and lower case letters and no spaces.
I tried changing it to that but it didn’t work. The animation name is correct too. Even when I call that animation from the drop down list instead of using an expression, it still doesn’t play. This only happens with the player character. I can change it to a different object and suddenly it calls the animation. Is it something about the way my player character is set up? I’m using the Top Down RPG Template and I just replaced the player character with my character. The player has the behaviors Top Down Movement, Top Down Movement Animator, and Top Down Multitouch Mapper. I tried deleting the second two thinking their settings were in conflict with what I was trying to do, but it didn’t work.