Add Recoil/Knockback to a player sprite

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello all, first post here.

    I'm attempting to make a 2D action platformer, the player sprite has a weapon sprite (a gun) attached to them which aims and fires towards the mouse cursor.

    I would like firing the gun to apply a large knockback to the player, in the opposite direction to which way the gun is facing. Physics behaviour seems the most straightforward way of doing this.

    I'm aware that attempting to mix platform behaviour and physics behaviour on a sprite is regarded as a bad idea so I've got the player as a having physics behaviour but not platform, movement is done with forces and impulses, is this also a bad idea? An issue I'm finding with this is that having 'Jump' as an upward impulse causes the player to lose all sideways momentum.

    Having firing the gun apply an impulse away from the mouse cursor doesn't seem to be working. Could this be because the weapon sprite is pinned to the player sprite? Would it be better to just set the weapon sprite X, Y to the player sprite X, Y every tick?

    My project is very rudimentary at the moment and I'm still working on a lot of the fundamentals so I don't think there is much benefit to sharing the .capx at this point.

    As you can guess, I'm a noob at this so any help is greatly appreciated, even just general tips and pointers. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use the Platform behaviour and set the X vector to the opposite direction of the gun.

  • robin Sommer is correct. Add the behavior "Physics" and apply an initial 1 time force each time he fires and you will get the effect your looking for.

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