Hi guys!
I am making a platformer and I stuck with this problem.
How do i make an enemy push/bounce the player backwards on collision?
Printable View
Hi guys!
I am making a platformer and I stuck with this problem.
How do i make an enemy push/bounce the player backwards on collision?
To assist you, one needs to know your starting point and your desired destination quite precisely.
1. Are you using the non-physics platform movement (hint: don't), the physics platform movement, or something else?
2. Do you mean a gentle shove or a forceful knock-back?
Right now I can only suggest experimenting with adjusting the X coordinate of your player object, and checking whether the enemy is to the left or right by comparing X coordinates for the two objects.
Thanks for your reply!
1. It's physics platform movement
2. I meant shove back
Problem solved.
Enemy is running towards Player randomly from left/right
On collision
if Player X axis position > Enemy X axis position
ADD 100 (or any number you like) to Player X axis position
SUBTRACT 20 from Player Y axis position
On collision
if Player X axis position < Enemy X axis position
SUBTRACT 100 (or any number you like) from Player X axis position
SUBTRACT 20 from Player Y axis position
nice solution! I know when you use an 8 movement direction you can select bounce.