## 2 Wheel Collision Detection

Member
Posts: 509
Joined: 2002.05
Post: #1
In my new game, I have a motercycle that is driving over terrain, so I need to go about collision detection differently than golf. Right now I have the front wheel working correctly, it acts like gl golf right now.

Basically, how do I go about making it work with 2 seperate wheels, has anyone else done this before? I want it to look correct and act correct, so if you move over a cliff slightly the front wheel crawls over and then brings the rest over next
Sage
Posts: 1,487
Joined: 2002.09
Post: #2
This should give you a pretty good idea of how to do it.
Gamasutra article

You might find SPK to come in handy here. I haven't really worked on it for a good month now, so I'll warn you that the documentation isn't really up to date. You'll also have to write a 3D terrain collider, I never got around to it.

SPK

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Moderator
Posts: 522
Joined: 2002.04
Post: #3
The two things Scott pointed out are the way to go. That article rocks. I spent months trying to do something similar working out complex differential equations based on Newtonian physics and those ways suck. My missing key was verlet integration. The rest falls into place once you start using that.

It works greatly.

-Jon
Member
Posts: 509
Joined: 2002.05
Post: #4
I just read the article, and I think I have a general idea of how to do it, I will definitly read it again, and then try it out in a 2D environment first
Sage
Posts: 1,487
Joined: 2002.09
Post: #5
I over-read where you said that you already had collisions working for the terrain. All you need to do now is simulate the back wheel the same way and "jam" them back together after colliding both wheels with the terrain independently of each other. It's such a simple solution that it made me cry having also spent so much time trying to figure out a "better" way like aarku was saying.

Simulating the wheels as spheres has some obvious limitations, but trying to do anything fancier will get really complicated really fast.

Anyway, feel free to poke around with SPK. If all you need now is some code to relax the link between the points, then you're in luck. That was the first thing that SPK did.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Member
Posts: 509
Joined: 2002.05
Post: #6
Skorche Wrote:I over-read where you said that you already had collisions working for the terrain. All you need to do now is simulate the back wheel the same way and "jam" them back together after colliding both wheels with the terrain independently of each other. It's such a simple solution that it made me cry having also spent so much time trying to figure out a "better" way like aarku was saying.

Simulating the wheels as spheres has some obvious limitations, but trying to do anything fancier will get really complicated really fast.

Anyway, feel free to poke around with SPK. If all you need now is some code to relax the link between the points, then you're in luck. That was the first thing that SPK did.

How do you recomend "Jamming" them back together, do you have any code or anything from that?
Sage
Posts: 1,487
Joined: 2002.09
Post: #7
Yeah, get SPK. It's there. The function PK_projectParticlesWeighted is the function that actually moves the particles, and PK_relaxLink is the function that processes the link and calls the projection function.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Member
Posts: 509
Joined: 2002.05
Post: #8
I decided to add this link to my new thread with the results - http://www.idevgames.com/forum/showthrea...#post65005 in case anyone is searching, adding this to my motorcycle is going to be so easy