Hello. I am trying to code (without using the New Input Package) 2D player rotation for my game. However, I’m stuck on how to do it. I want it so that up arrow always faces up, but up + right always faces the top right diagonal. This is what I have so far:
//This is not working for me. These two inputs are left/right arrow
//and up/down arrow respectively. The character defaults facing to the right
float rotH = Input.GetAxis("P1_Rotate_Horizontal") * -180;
float rotV = Input.GetAxis("P1_Rotate_Vertical") * 90;
//Get current and desired rotation
Quaternion currentRot = transform.rotation;
Quaternion targetRot = Quaternion.Euler(0, 0, rotH + rotV);
//Get new rotation and assign it
Quaternion newRotation =
Quaternion.RotateTowards(currentRot, targetRot, rotateSpeed * Time.deltaTime);
transform.rotation = newRotation;