I am making a simple first person game. I created a simple move script that i would build upon. I am using the MouseLook script from the character controller package. I am using rigidbody.AddForce to move my character around. I use this code to move my character forward: rigidbody.AddForce(transform.forward * 5000). It works fine but the only down side is if I look up and call that code it enables me to fly. I don’t want that to happen. Is there a way to restrict the forward to only the y axis. I just want it to move forward in the y direction my character faces. Is there a easy way to fix this or use a different way to do this instead of rigidbody.AddForce.
rb.AddForce(new Vector3(transform.forward.x, 0 , transform.forward.z) * 5000);