I’ve been testing out wheel Colliders for a while and they are great for 90% of the time but I run into issues that I can’t seem to get around. Because the wheel collider is essentially a fancy ray collider it never takes into account the presence of the whole wheel. Only a line directly to the ground.
How could I get the wheel to react if it hits somewhere (on the actual wheel) other than ray collider.
Wheel works fine in this situation…
but it cuts through the ground if the vehicle is on a strange angle…
and doesn’t react nicely with objects that are in front of it.
The wheel collider doesn’t work well when the surface is very bumpy (like an off-road car game, say) for exactly the reasons you mention. However, you can handle small obstacles by placing a capsule collider in the position of the wheel. If you make the collider slightly smaller than the wheel and give it a frictionless physic material then it will tend to lift the wheel more gently over obstacles rather than giving that sudden bump when the ray hits a higher surface.
That’s cool, but wouldn’t that mean that any collisions with the capsule would feel really rigid since they wouldn’t affect the suspension of the wheel?
Does anyone have any other ideas for this? Or maybe another approach? I was thinking of making a suspension rig with physics constraints, does that sound plausible?
If one is to make a dirt bike game similar to these in unity, how would this be done?
I tried using wheel collider, and then rotate the wheel so that the raycast is facing in the direction of a collision (of a sphere around the wheel) (for uneven surfaces). I had some success with this but is not very reliable since the collisions are not 100% accurate.
there is an elegant solution to this.
you need to get rid of the wheel collider and implement your casting wheel by your self using sphere cast instead of raycast.
Thats what I did with my UnityCar package. You can try some online demos on my website.
Congratulations, obviously this is what we are crying out to recreate !
I check out sphere casting and then started to look at the unity wiki’s wheel collider source code to see how the original ray cast could be changed out for sphere casts instead. I do believe at the moment i’m in slightly over my head with only a beginner level in scripting knowledge.
Michele I realizes you have this brilliant product and you don’t want to give away all your secrets however any insight you can give us in setting up a sphere casting wheel collider would be massively appreciated.