r/UnityHelp • • Mar 02 '21

Gun recoil

I already have bullets and stuff planned for later, but for now I want to make it so that when I click the left mouse button, the player object gets propelled in the opposite direction. How would I do this?

3 Upvotes

3 comments sorted by

2

u/DeckOfDubstep Mar 02 '21

You can add a rigidbody to your player and use it in the script to addforce back :)

1

u/FantasticCrab3 Mar 02 '21

I had that part, but how can I take the rotation of the camera (instead of the mouse direction because I have variable sensitivity) and turn it into a direction to add force?

1

u/DeckOfDubstep Mar 04 '21

You need to use transform.forward or backward or right or left from the camera to use in your rigidbody addforce