- Home /
Car wheels geometry rotates on y axis when "Play" is pressed, Unity
So am making a car game and Currently moving from the test version to the production one.
everything was going on smoothly until I brought in the replacement for my test car model (which was exported in the default fbx. settings)... anyways so I brought in the replacement and applied my code to it, the car worked fine and it was moving but for some reason the wheel geometry always rotates 90 degrees on its y-axis. The code works by applying the transform information of the wheel colliders to the wheel geometry.
// this function will update the car's wheels' positions and rotation as they are moving.
private void UpdateWheelPosAndRotation()
{
UpdateIndiWheelPosAndRotation(FPW, FPT);
UpdateIndiWheelPosAndRotation(FDW, FDT);
UpdateIndiWheelPosAndRotation(BPW, BPT);
UpdateIndiWheelPosAndRotation(BDW, BDT);
}
//this is the helper function to the one above... It will take the wheel info from the collider and apply it to the transform.
private void UpdateIndiWheelPosAndRotation(WheelCollider _wheelCollider, Transform _transform)
{
Vector3 _pos = _transform.position;
Quaternion _rot = _transform.rotation;
_wheelCollider.GetWorldPose(out _pos, out _rot);
_transform.position = _pos;
_transform.rotation = _rot;
}
The wheel's y-axis rotation stay normal when I delete this piece of code.
and this is a picture of what happens when I press play
Any ideas on what to try, please comment that idea
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Wheel Collider Rotation 0 Answers
Car trembling when reaching a certain speed 1 Answer
Custom Wheel Collider Suspension 1 Answer