How I solved the rotation constraint problem

Ben says that it’s tricky to work around the physics engine and also having constraints on the rocket. He suggests not fixing it and instead fly carefull.
This was driving me nuts since crashing into friendly but moving walls happens all the time in one of my level.
I solved it by resetting the X and Y on rotation (called from Update()). Might be a bit overkill and if someone else has a better solution I’d be grateful to hear of such a solution.

But here’s how I did.

private void FixRocketRotation(bool full)
    {        
        if (full) //Make everything straight
            transform.rotation = Quaternion.Euler(0, 0, 0);        
        else //keep only Z since that's fine.
            transform.rotation = Quaternion.Euler(0, 0, transform.localRotation.eulerAngles.z);
    } 

Privacy & Terms