Spherical movement in relation to oriantation
I am trying to make my rigidbody based movement take the orientation into account so it will move in the direction the player is looking. My player is a sphere and so has some different movements that I would like to keep.
horizontalMovement = Input.GetAxisRaw("Horizontal"); verticalMovement = Input.GetAxisRaw("Vertical"); // Calculate how fast we should be moving if (isGrounded) { targetVelocity = new Vector3(horizontalMovement, 0, verticalMovement); targetVelocity *= speed; } // Apply a force that attempts to reach our target velocity Vector3 velocity = rb.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0; rb.AddForce(velocityChange, ForceMode.VelocityChange);
Any help is appreciated thanks