How do I setup a knock back effect?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hello, Im trying to add a knock back effect when you run into an Enemy but I cant seem to get it working correctcly. I'm using (Compare X) to tell it what side of the enemy the player is on than I add a (Set Vector X) for the knock back direction. The right side of the Enemy will work kinda of,except it wont kick the player back, instead it will only stop the player from moving forward like it's a solid wall. The left side will not work at all even when I copy and past the right side code and change the direction, the player will walk right through the enemy like its not there. not sure what I'm doing wrong.

    Please Help thank you :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In the second sub-event add "else". Also you don't need to use "Self.X". Just use the value -100 for knocking right and 100 for knocking left. To make it work better you should also mess around with setting the player's deacceleration lower to make the knockback more powerful.

    Hope this helps.

  • Also, the vector can't be higher than the player max speed. If you want a fast and powerful knockback, you might need to temporarily increase the platform max speed.

  • Hey, Sorry for the late replay.

    I got it working, I did what you both suggested but it still didn't work for me :( so I got rid of the (Compare X) Condition and instead added the Enemy to a Families folder, than added a (Player on collision With Enemies) condition, and used just the (Set Vector X) It works great now :)

    Thank you Both I appreciate it.

    Here is a pick of the code.

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