Search Unity

Trouble with WheelCollider, What options have I got.

Discussion in 'Editor & General Support' started by petey, May 26, 2011.

  1. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    Hi there,

    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.


    Any ideas would be great!

    Thanks
    Pete
     
  2. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Yeah, I'd also be interested in a solution to this...
     
  3. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    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.
     
  4. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    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?
     
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    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?

    Thanks
    Pete
     
  6. ivkoni

    ivkoni

    Joined:
    Jan 26, 2009
    Posts:
    978
    Do we have a solution for this?

    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.

    Is there something that does work?

    thanks
     
  7. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    I'm looking for the same solution, did you turn anything up yet ?
     
  8. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
    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.

    Regards,
    Michele Di Lena
     
  9. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    Michele thanks for your reply, am going to look up sphere casting right now !
     
  10. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,823
    Thanks NewLife, Sounds interesting I'm gonna check that out today!
     
  11. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
    This is a tech video showing real life differences between standard wheel collider and UnityCar 3D tire:

     
  12. LS16BMX

    LS16BMX

    Joined:
    Nov 11, 2011
    Posts:
    94
    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.

    _matt