How to make Character launch the opposite direction after shooting??

Hi.

I am very new to coding, and want to make a 2d game where the main premise is that you have to shoot your gun to move.
I’ve made the looking scripts and the shooting scripts, I’m just confused on how to actually make the gun make YOU project.
Any help would be appreciated!
Thank you!

If your character is physics-based (is moved by a rigidbody component), you can use rigidbody.AddForce() to simulate physic forces. I’d recommend you using rigidbody character controllers as they’re much more precise than permanently teleporting the player with tranform

1 Like
var direction = -gun.transform.forward //Opposite direction of the gun
var direction = -tranform.forward; //Opposite direction of the player's forward vector
//Chose only one line from above, remove the other one.

PlayerRigidBody.AddForce(direction * 100)
1 Like