on-internet
← Community

Correctly move rigidbody at constant speed

Stack Overflow ·

This is currently my code. The object moves at the desired speed but using rb.velocity = movement * speed if it jump it remains glued to the ground. I can't understand how I can fix things. private Vector3 movement; private float speed = 3; public bool isGrounded; void Start() { rb = GetComponent<Rigidbody>(); } void Update() { float Horizontal = Input.GetAxis("Horizontal"); float Vertical = Input.GetAxis("Vertical"); movement = transform.right * Horizontal + transform.forward * Vertical; float origMagnitude = movement.magnitude; movement.y = 0.0f; movement = movement.normalized * origMagnitud

Comments

Sign in or sign up to comment and upvote.

No comments yet.