got an issue where my ship turns when i change the yaw factor but i can’t find a problem within the code
somehow the z rotation doesnt change
is it a perspective problem? i changed the field of view but it changed nothing
can someone help?
thx
[SerializeField] float speed = 30f;
[SerializeField] float xRange = 24f;
[SerializeField] float yRange = 12f;
[SerializeField] float positionPitchFactor = -2.5f;
[SerializeField] float positionYawFactor = -0.5f;
[SerializeField] float controlPitchFactor = -20f;
[SerializeField] float controlRollFactor = -20f;
float xThrow, yThrow;
void Start()
{
}
// Update is called once per frame
void Update()
{
ProcessTranslation();
ProcessRotation();
}
private void ProcessRotation()
{
float pitchDueToPosition = transform.localPosition.y * positionPitchFactor;
float pitchDueToControlThrow = yThrow * controlPitchFactor;
float pitch = pitchDueToPosition + pitchDueToControlThrow;
float yaw = transform.localPosition.x * positionYawFactor;
float roll = xThrow * controlRollFactor;
transform.localRotation = Quaternion.Euler(pitch, yaw, roll);
}