I am creating a real time multiplayer driving game in Unity. I am using google play's real time multiplayer service. I am having an issue where the wheels of the cars that are over the network are not facing the right direction. What I am currently trying to do is just add the calculated steering angle to the current rotation of that particular player's car, but for some reason the wheels face the wrong way and rotate incorrectly if the car is facing certain directions. Logically I thought what I have is correct. Basically for each wheel I use this code:

car.transform.rotation = Quaternion.Euler(0, car.transform.rotation.y + steerAngle, 0);

So I find the rotation of that car and then I add the steer angle to it. Why wouldn't this work?


1 Answer 1


Assuming the wheels are children of the car, it will be easier to apply steerAngle to transform.localRotation. The numbers you see in the transform's inspector are local, not world. By adjusting/transmitting the local rotation for the wheels, you can apply them directly and let the transform hierarchy worry about getting them to come out right in world-space. You can rest assured that the local rotation is always relative to the parent car.

The wheel rotates constantly on its' local X axis whenever the car is moving forward. The wheel "steers" by rotating along it's local Y axis. In both cases, the wheel is only rotated around its' own, local, origin; unbeknownst to the wheel, that origin is actually moving all over world-space.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .