0 Favourites

Enemy Pushing Away

  • 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.

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
78 10,778
Josek5494's avatar
Josek5494
Unread hot topic
51 10,469
irina's avatar
irina
Unread hot topic
46 9,325
matrixreal's avatar
matrixreal