2
\$\begingroup\$

I am currently working on a shooter and I could use some help with this. I want to make my character knock back when he shoots, but also the knock back should be different when the player uses a different weapon. How can I do this?

\$\endgroup\$
1
  • \$\begingroup\$ This is difficult to answer without information about how your player movement works at present. If you're still looking for help with this, please consider adding the relevant portions of your player movement script so users can understand what they have to integrate with. There are lots of ways to move a player, and each can require different knockback strategies to ensure one behaviour doesn't override or mix badly with the other. \$\endgroup\$ – DMGregory Feb 21 '18 at 23:57
1
\$\begingroup\$

It sort of depends on the game engine you're using, but you can accomplish this effect by adding some relative force in the opposite direction of your character.

For each weapon, you will designate some force for the variable, and when you fire, apply that amount of force to your actor.

To add a little more cool effect, you can even make the camera shake some, or add some recoil to the camera.

If you're using Unity, for instance, you can check out RigidBody.AddRelativeForce documentation. You'd add the force on the Z axis, in the opposite direction.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I added the Unity tag so I am using Unity \$\endgroup\$ – user110547 Dec 13 '17 at 2:03
0
\$\begingroup\$

Just animate the knockdown behaviour, create different animations with different weapons in some software like maya, blender etc and use it directly in Unity.

Unity uses Mechanim in which you can blend different animations in a same state. Although blending is used to blend two or more similar motions but it can also be used to play different animation in same state in different scenarios.

Tutorial for blend trees can be found here.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.