I want the player to be knockeed back a bit when in collision with an enemy and for the animation to change but neither is happening. Firstly, the animatoin doesnt change and secondly, when the player is in collision with the enemy, it slowly, smoothly moves back (like a tween animation). How can i fix this?
Hi, in your collision events you need a’ Trigger once while true’ condition, otherwise the collision is constantly checked and your animation won’t play.
Hello! I’ll help you in a way, but maybe you’d rather make some change according to your game.
You need one more condition in your first event of “Player Animations” group, otherwise when you try to make your Slime change to animation number 4 when it get hited it will comeback to number 2.
In your events with the collision you can:
- add the same condition like before to make your collision happens just 1 time
- add the action to ignore your default controls of platform character behavior so you can’t move it while taking damage
- change in your action “an instant” to “a permanent”. So, your force will be permanent making a new event necessary to stop your player.
- Make a new event for when your animation 4 finishes the player regains control and the force that moved him before stopping acting (you’ll probably need to put more frames in this animation and adjust your runtime)
Maybe with this code you may have some difficulty if the character is “trapped” between multiple enemies taking damage infinitely. If this occurs in your game, the ideal is to modify the code and use a timer as a condition in the collision event.
woooow! thanks for the intelligent, logical feedback, so far it’s working way better than the old code. Except the force, it isn’t applying for some reason but I’ll figure it out, Thanks again.
oh ok, thanks, I’ll try that out!