Car rotation

So… Does anyone else have this issue whereby as you drive your car around, the sprite starts rotating in x and Y making it very hard to control? the car should only rotate around z right? and it shouldn’t change its z position either.

Hi,

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture? The car is supposed to rotate around the z-axis only.

Yeah i’ve compared the code. usually you can contrain rotation around any axis, but my unity is only offering constrains to rotation about the x and Y Axis. In addition, what appears to be happening, is that my Car is being shifted in the Z-Axis. So the camera is at -10, the game field is at 0. and my car seems to be ebing forced and rotated into Zaxis + increments, which means that i essentially fall off the game board. So im not sure whats going on here

and

image

after a few seconds ::
image

Its not staying within bounds.

Its OK! I found the issue! for some reason in my code i had not hard-coded 0’s into the transform.rotate method. its all sorted now with

transform.Rotate(0, 0, -turnAmount); and transform.Translate(0, acceleration, 0); previously these had variables instead of 0’s! silly me

1 Like

Good job on solving the problem! And thanks for sharing your solution! :slight_smile:

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

Privacy & Terms