Some code I wrote to fix the x and y rotation 'bug'

I noticed in the lecture (picture attached but it’s sort of hard to tell) that after bumping into the obstacle, the rocket seems to rotate slightly in the x and y axis - like as though it’s leaning towards the camera or away from it. It doesn’t look good to me, and maybe this is fixed in a later lecture but I wrote this method which, on every frame, sets the x and y axis rotation to 0 while keeping the z rotation unchanged.

image

image

image

It’s called after the methods that handle the thrust upwards and the left/right rotation. In my basic testing using the one cube obstacle in the lecture it seems to work fine.

1 Like

It’s been a little while since I did this course, but if I remember correctly Rick will fix this later by freezing rotation in the Rocket’s RigidBody Component (under Constraints).

Kudos for spotting a bug and working out your own way to fix it!

1 Like

Privacy & Terms