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
Quote this message in a reply
Sage
Posts: 1,482
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.
Quote this message in a reply
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
Quote this message in a reply
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 Smile
Quote this message in a reply
Sage
Posts: 1,482
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.
Quote this message in a reply
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?
Quote this message in a reply
Sage
Posts: 1,482
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.
Quote this message in a reply
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 Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  2D Pixel Collision Detection using OCCLUSION Elphaba 0 3,326 Jun 8, 2009 06:30 AM
Last Post: Elphaba
  the best way to do collision detection ghettotek 26 10,285 Jun 4, 2009 02:30 PM
Last Post: AnotherJake
  Hierarchy, gluProject and collision detection lemtoo 3 4,675 Nov 30, 2007 09:26 AM
Last Post: lemtoo
  multi-level collision detection alert 0 1,743 Apr 7, 2005 10:27 AM
Last Post: alert
  Quad Collision-Detection Duane 5 5,280 Jan 18, 2005 01:42 PM
Last Post: Duane