Hi, I am a noob to c# and Unity and all this, and I am trying to make it so when I press W, It applies a force in the direction the camera is facing. I already have the direction I want to use stored in Mouse_X, I just want to apply a force in the direction of Mouse_X. If somebody could just explain how to do this with an example I would be so happy! I have been searching for a tutorial or an example or anything that I can use to help me. Even if its impractical, I just really want to do this!
Hey @Qweazi i am assuming your game is 3d based game. So if you have the direction in which you want the object to displace by using force than first apply rigidbody to the object. Because Rigidbody is an essential component for applying physics in your game.
Rigidbody.AddForce(Direction, Force Type );
Simply put your direction which you have stored.
about Force mode then these are the modes Impulse, and Velocity Change, Force ,Acceleration
I would suggest try all of these so you will choose better mode for it.
for Reference : Unity - Scripting API: Rigidbody.AddForce check it out
1 Like