Enemy Pushing Away

0 favourites
  • 4 posts
From the Asset Store
Push the Box Puzzle Game
$10.80 USD
10% off
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • Hello everyone.

    I am making an overhead game, and I just got down the health bar and the player takes damage upon collision with another enemy. But what I would like to know, is how do I make the player be pushed back away from the enemy when coming into a collision with him.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You will probably have to use the physics behaviour, although I think there might be a way without it but then again I'm not to sure how without physics.

    Someone will probably give you better answer. But I guess the logic would be:

    Event: if enemy is in collision with player

    ---> Action: enemy applies force to object(The Action is "Apply Force")

    I'll see if I can make a capx with it later and get it working unless someone already does it.

    Hello everyone.

    I am making an overhead game, and I just got down the health bar and the player takes damage upon collision with another enemy. But what I would like to know, is how do I make the player be pushed back away from the enemy when coming into a collision with him.

  • Yeah you don't need physics for this :P Assuming you're using the 8 directional behavior..

    Give your player a variable, lets name it "hurt".

    When the player gets hit, set "hurt" to 10, set his deceleration to 100 or something else very low, set his angle of motion to the angle between himself and the enemy using angle() and finally set his speed to however fast you want him to be knocked back.

    Now if that player variable is greater than 0 then subtract, say, 30*dt. When it's lower or equal to 0, activate your player event group and reset his deceleration.

  • Thanks a lot Tokinsom!

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