void ProcessRotation()
{
// x,y,z = pitch, yaw, and roll
// when we go up/down the y axis, we rotate by the x-axis
float pitchDueToPosition = transform.localPosition.y * -positionPitch; // position impacting pitch
float pitchDueToControlThrow = yThrow * controlPitchFactor; // control impacting pitch
float pitch = pitchDueToPosition + pitchDueToControlThrow;
// the yaw changes based on the position on screen (left/right)
float yaw = transform.localPosition.x * positionYaw;
// when we move right/left the z axis, the roll changes
float roll = xThrow * controlRollFactor;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}
This is my code.
I don’t quite understand why we need both player input and the position on screen for the pitch. Can’t we just use pitchDueToControlThrow
to control the rotation?