How to rotate player control of ball (based on 'roll a ball' script)
I want to be able to use an input which I've named "TurnBall" (with the Q button for negative input, and E for positive input) to be able to rotate the direction my main force controls move me. Here's the code currently used for moving the ball around. public class PlayerMovement : MonoBehaviour { public float speed; public float strength; private Rigidbody rb; private void Start() { rb = GetComponent<Rigidbody>(); } private void FixedUpdate() { float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); rb.AddForce(movement * speed); } }
What i'm going for is that if I were to press either Q or E, the orientation of the controls would be turned, so that I could aim myself in any direction before or during movement.