The following problem occurs both in Unity 2.5 and 2.6
I have a script-controllable vehicle with 8 wheel colliders; the vehicle is using asymmetric steering, so the rear 4 wheels rotate opposite the front 4 wheels. My script has a target point and target speed, and it uses PID controllers to generate thrust and steering angles that are fed to the wheel colliders. Thrust is only applied to the 2 rear wheels. The problem/bug is that after running for a few seconds, Unity freezes requiring me to kill the process. With nothing else running, I am pretty certain the problem is in the script.
After leaving it ‘frozen’ for almost 10 minutes, a bunch of messages pop in the console; most are: “Quaternion To Matrix conversion failed because input Quaternion is invalid”, but the system remain frozen so I can’t check values of variables or scroll in the console.
Things I have tried:
- reduce time step - no change
- change wheelcollider parameters - no change
- move the initial position of my vehicle - error happens later, or at a different point
- ensure steerAngle and torque are within bounds, using Mathf.Clamp - no change, in fact error occurs when steerAngle is near 0
- setting steerAngle to 0 when it is near 0 - no change
- setting steerAngle through the inspector while the game is running - works fine, but I want my script to be driving, so this doesn’t help me.
I have hit a wall, so to speak, at this point. To be sure, I did a search on the ‘invalid quaternion’ message, and suspiciously I have seen no response from Unity folks on the error, possible causes, or approaches to tracing such problems. In fact, most messages listing this error go un-answered.
I am not saying this is necessarily a bug, but is a problem that for me at least, has more-or-less halted any development with Unity, so any help or guidance would be greatly appreciated at this point!
I have attached the guiding script.
219271–7967–$drivestraddle_860.js (5.57 KB)