Ship rotates, need help

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 :slight_smile:


[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()

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);

Hi Felix,

Tweak the four float values a bit in your Inspector to see if that improves the result. You could, for example, set them to 0. Does the ship look fine in that case? If not, the issue is probably somewhere else. If it does look fine, increase the float values slightly until you are happy with the result.

i played around a bit with the camera and it seems like an perspective issue
now it works somehow, but thanks a lot :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms