Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Collision With Spheres

Author
Message
Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 15th Dec 2006 03:15
Why doesn't this work? I've tried help files and tutorials, but ofund nothing on spheres.



Thanks Again!!

"There will always be evil, for, without evil, the good shall lose their virtue."
BF game programmer
20
Years of Service
User Offline
Joined: 22nd Jan 2005
Location: hoover alabama
Posted: 16th Dec 2006 04:58 Edited at: 16th Dec 2006 05:06
this works but it only hides the object and doesnt delete it.


this also kind of works in the way you want and it deletes the objects


Boba Fett - "put captin solo in the cargo hold"
Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 16th Dec 2006 23:08
Actually, niether of those worked for me. The collision is detected with the box, but not the sphere. Might it be because I'm using the trial version untill Christmas?

"There will always be evil, for, without evil, the good shall lose their virtue."
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 16th Dec 2006 23:34
Try using IF OBJECT COLLISION instead of IF OBJECT HIT.

The OBJECT HIT will only return a value of 1 if the object collides once for the first time, while OBJECT COLLISION will return it for the entire time that the object is colliding.

Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 17th Dec 2006 00:13
Unfortunately, it's not that easy. Same results with your mod:


"There will always be evil, for, without evil, the good shall lose their virtue."
Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 17th Dec 2006 08:25
I found that in the object collision code, you must use the sphere first as the first number. Why is this the case?



"There will always be evil, for, without evil, the good shall lose their virtue."
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 17th Dec 2006 13:29
Oh I didn't notice that! I think it's because the sphere is moving.

Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 17th Dec 2006 20:23
Quote: "Oh I didn't notice that! I think it's because the sphere is moving.
"


What? This is the code I was reffering to, and the sphere stays still; it's the cube that moves.



"There will always be evil, for, without evil, the good shall lose their virtue."
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Dec 2006 21:18 Edited at: 17th Dec 2006 21:20
It's easier to use a zero in the collision check... that way you don't have to repeat commands to do the same thing or check if the object exists before checking collision.

Ankillito
18
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 17th Dec 2006 22:54
I copied and pasted that code into DB, but it did nothing to the sphere!! What's going on?!? Again, might this only be happening to me because this is the trial version?

"There will always be evil, for, without evil, the good shall lose their virtue."
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 17th Dec 2006 23:01
most probably.
run the collision demo from the trial version as well to confirm.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Dec 2006 12:20
I just tested that in Classic (wrote in Pro) and I now see what you mean. The sphere stays there as if it was never hit (though clearly goes right through it).

This has got to be a major bug in Classic... the only bad thing is it won't ever be fixed. In Pro it works like a charm... so when you decide to buy Darkbasic... make sure it's Darkbasic Pro. Pro is much faster and better anyway.
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 20th Dec 2006 14:06 Edited at: 20th Dec 2006 14:07
try my "sphere collision" snippet: http://lukasw.com/?page=codebase&status=show&nr=2.

it should give you an idea of how to check for collision with spheres,
if you're having trouble implementing it i've done it for you:



Login to post a reply

Server time is: 2025-05-26 03:32:34
Your offset time is: 2025-05-26 03:32:34