PS: I miss being able to delete threads and change thread titles… I hate cluttering up the forums. This thread was originally about something else that I figured out, but I’ll reuse the thread.
Ok, so I’m creating a prototype for a wacky game with a vehicle – I’m using wheel colliders, but they don’t seem to apply motortorque when upside down. I guess this isn’t a very common situation to see in a game… imagine a rollercoaster upside down – the coaster part is bellow the track, but the wheel is above the track preventing them from falling – if that wheel spins, they move. I need it to work both ways.
Am I correct in understanding this? In example A, the ray cast downward detects road and will be able to apply motortorque. But in example B, the ray doesn’t detect anything so no motortorque, but the wheel is obviously still contacting something visually and should have an effect.
So what should I do instead? Some way to dynamically change local rotation of wheel collider? Or should I not use wheel colliders and come up with my own solution – any links to help me get started with that?
You should be getting an OnCollision event from the wheel colliders if they are in contact with the “track” or ground, shift the direction/rotation of the raycast toward the track based on collision.
Alternatively, you could use a Physics.SphereCast, instead of a directional raycast to detect the track/ground.
I’ll have to see how that would affect my joint setup and the rest of the vehicle, but ideally the solution bellow ends up working out…
Yeah but as far as I know, wheel collider hides it all behind the scenes. I’ve been playing around with using yoggy’s car/wheel stuff so that I have complete control, but I’m getting stuff like
“transform.localRotation assign attempt for ‘Graphic’ is not valid. Input localRotation is { NaN, NaN, NaN, NaN }.
UnityEngine.Transform:Rotate(Single, Single, Single)”
I opened up his example project in U3 – worked fine – did some work on it in that project to get it doing what I needed and then moved it into my project as a package, but now I get these errors.