Posted: 4th Jun 2007 10:38
Hi, I'm writing a racing game, and until now is going very well, but now I'm stuck with collision, I made the road, and for all around the walls in road I made planes with 3ds and export as .x files and now I want to make collision to that planes so car can't go through the walls I use only dbp code:

for i = 100 to 208
if object collision (1,i)
text 10,10,"Object collision"
endif
next i

p.s. where 1 is number of car

but I have a problem because nothing happen, so please if anybody know where is the problem please help me, maybe I'm made a mistake about planes, or something but I'm stuck for a while.

Thank You in advance
Posted: 4th Jun 2007 19:11
Try using the OBJECT HIT rather than OBJECT COLLISION. OBJECT COLLISION requires the objects to overlap each other before an integer is returned, whereas OBJECT HIT will return one when they touch each other.

Also, if the walls you're colliding with are planes, then you *may* want to change them to boxes. Planes are not so hot for collision, especially at higher speeds. In point of fact, DBP collision commands at higher speeds in general are quite inaccurate.

Beyond that, I would say that the collision native to DBP is fairly not fun to deal with =P If you have an extra 20 bucks lying around, I would purchase Nuclear Glory's collision Dll, which is fantastic. If you're poor (like me atm =P) then I've heard that Sparky's collision Dll is great, though I have not used it myself.

Cheers, hope you get it worked out =)
-Bishop
Posted: 4th Jun 2007 22:25
Actually you don't need the loop.

You can replace:

+ Code Snippet
for i = 100 to 208
  if object collision (1,i)
    text 10,10,"Object collision"
  endif
next i


with:

+ Code Snippet
ObjHit = Object Collision (1,0)
If ObjHit
  Text 10,10,"Collided With Object "+Str$(ObjHit)
Endif


I also suggest you stick with Object Collision rather than Object Hit as Object Hit is a 'one shot' event that doesn't repeat until the objects concerned are separated and collided again.

If you miss the exact moment the 'hit' is fired you've had it.

Object Collision however keeps firing the collision value all the time the objects are colliding so it's not as time-sensitive to when you test for it.

Tip: Highlight any code you post and click on the Code button - it keeps all the formatting intact when you do that!

TDK_Man
Posted: 5th Jun 2007 0:55
I stand corrected =D GO TDK_MAN!
Posted: 5th Jun 2007 2:17
get sparky dll
Posted: 7th Jun 2007 2:45
Thank You everyone for posting and helping me, as I understand the best way is to use the sparky (cause it's free). I dowload it but now as I seen it's not very simple so please if anybody can post some code on how to collision to .x object.

Thank You so much, You guys are the live saver, thanks again
Posted: 24th Jun 2007 19:09
Here's an insight on what I've came up with to help solve your wall collision. I use IF OBJECT HIT(A,B) command cause OBJECT COLLISION(A,B) didn't seem to work for me.
Posted: 20th Sep 2007 22:02
Hi I am making a fps game and I have a map made in AC3D so it is a.x file... and a player that is .X to. Do someone know how to make the player to "walk" and not fall through my map???