How do I make enemies get pushed back when hit?

0 favourites
  • 9 posts
From the Asset Store
Helping streamers give their viewers more excitement.
  • My enemies have the Platform behavior on them (this is a side platform game). When the Player hits them with his weapon, I want the enemies to get pushed back, pause a little, and then pursue walking towards Player again.

    Right now, when they get hit, I use the move forward -50 event, but the issue is that this forces them into walls. What's the correct way to push them back?

  • I don't know exactly how to do it right now but using timer might help to split this action on parts (push them back -> start timer "stun" for 0.5 sec -> on timer "stun" -> start moving them forward).

  • Bezza Thanks, this is helpful! I also fiddled around a little bit and decided to use angle of gravity as well, wait 0.2 seconds, and make the angle of gravity default again.

  • Gravity doesn't seem like the best way anymore. The movement is very artificial. Does anyone have other ideas on how to push enemies back? Perhaps 'move to location with a parabola'?

  • you need to check the space you are sending them too for a collision before you do the move forward. If that spot is empty then proceed with the move otherwise do something else....or nothing but not the jump back move.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • you need to check the space you are sending them too for a collision before you do the move forward. If that spot is empty then proceed with the move otherwise do something else....or nothing but not the jump back move.

    What event would you use for the move forward? Path finding and follow path?

  • I did this a while back with bullet physics, setting the acceleration and deceleration based on a timer and the angle of motion based on where the player hit them from, it worked pretty well for a top down game

  • ChefSeth Thanks!

  • You could also use the Vector X when using the Platform behaviour. So for instance when an enemy gets hit you could set the Vector X to an amount, say 200, for this example (try out a higher or lower amount to see the impact),

    200 is a positive number so the enemy would "dash" off to the right - meaning you should check before the enemy takes the hit if the player/weapon, is left or right from the enemy that gets hit.

    If the player is on the other side of the enemy, on the right (I'm guessing it's a sidescrolling platform game), and the player hits the enemy to the left side - use -200.

    Hope that helped a bit

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)