Hey there, im looking for help trying to create a recoil or pushback from enemy hits or encounters, where; if the player gets damage they are pushed back. I feel like I once saw a guideline for this but now that im looking for it I cant find it. Thanks!
What have you tried so far? Can you share any code or relevant events?
- To move the player you want to use
goto
- To work out the new coordinates to move the player to you need to start with their current coordinates
event.px
andevent.py
- You'll also probably need the coordinates of the enemy. If an event is in the enemy tile script you can use
event.x
andevent.y
to get the coordinates of the enemy tile
Once you have the simplest version of knockback working then you can start improving it to deal with situations like the player being knocked back into a solid tile.
Hope that helps!
3 Likes