- Home /
Jump script not going in direction of movement
I'm using the below to make a simple jump for a 3D FPS but it seems to jump in a random direction, not the direction of movement
rigidbody.AddForce(new Vector3(Input.GetAxis("Horizontal"), jumpForce, Input.GetAxis("Vertical")), ForceMode.Impulse);
Is there a better way to do this?
Answer by AbdeCodeEnjoyer · Dec 25, 2021 at 02:55 AM
I think this is a classic case of your vector3 not being affected by the diection of your body or camera
//heres an exemple to try
//im also guessing that the body of player rotates in a y axis
//also note that right and forward might be interchanged (i didnt test this)
rigidbody.AddForce(transform.foraward * Input.GetAxis("Horizontal") + transform.right * Input.GetAxis("Vertical"));
Turns out the issue was the character controller. I was disabling it but apparently that's not good enough so I just went with a full rigidbody system.
Thanks though.
Your answer
Follow this Question
Related Questions
How can I add smooth movement to a RigidBody? 2 Answers
My player's camera displays jerky objects 2 Answers
How do I add force To rigidbody based On Character's Walking direction? 0 Answers
How do I stop my character from sliding after adding force? 0 Answers
Physic Based FPS Movement,Fps Movement Physic Based 0 Answers