WheelCollider - Problem with model rotation
First of all I have to mention that I have just started to get familiar with Unity engine, so my question is probably really basic. :)
As my first task I would like to create simple car with simple controlling so I followed this tutorial on Unity's site: WheelCollider Tutorial
I could achieve to control my car but I stucked at adding a visual model to wheel collider. Here is my object hierarchy and how I set the models:
And this is the scene and game windows:
As you can see on the scene screen the wheels' rotation is fine but when I start the game it goes wrong. The wheels are turning and rotating but on a wrong way furthermore the car is not moving when I rotating the visual models. If I turn off the visual rotation the car is moving.
My assumption is I cannot rotate the wheels' model on scene because it will be rotated back according to the script: (I'm using the same code which is in the tutorial)
collider.GetWorldPose(out position, out rotation);
visualWheel.transform.position = position;
visualWheel.transform.rotation = rotation;
So my questions:
How should I set the visual wheel models to display them correctly on scene and in game as well? And keep the car moving.
The tutorial gets first child transform and after that it gets again transform of visualWheel. Why it is necessary? Shouldn't we use only visualWheel?
Answer by 40detectives · Jun 29, 2017 at 04:34 PM
Hi, I encountered the same problem as you.
For the first question I already posted a solution in the forums, here.
What you are doing in the tutorial script is saving a reference to the position an rotation of the visual wheel object first, and later, after the changes in the WheelCollider happen (that's why it's exec from the FixedUpdate), you update your visual wheel object with the collider's position and rotation.
Hope this helps.
Your answer
Follow this Question
Related Questions
Imported Models Not Rendering Correctly? 5 Answers
How to create a plot system 0 Answers
How do/should I make my character jump? 1 Answer
Is there any way to remove the seam in this character mesh? 0 Answers