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.

Newcomers DBPro Corner / Problem with collisions

Author
Message
HoverFrog
21
Years of Service
User Offline
Joined: 7th Aug 2003
Location: Canada
Posted: 16th Oct 2003 22:54
Hi folks.

I made a 3d model(space ship) and i use it in a .x format. I also have another ship (the player's ship) on wich i attached the camera to the cockpit. I test the collision between the two using Object collision(object A,0) which returns the number of the object being collided with.

My problem is that it does not detect the collision until the player's ship is deep within the other ship (around the center of it).

PS It seems that it will not detect any collision if global collision is Off even if i set collision on to the specific objects.

I have tried spheres,boxes and polygons collisions and nothing works, anyone with an idea would be very appreciated...
KNau
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: Canada
Posted: 17th Oct 2003 03:22
You could try using a proximity check rather than a true collision test. If you know your ship is 100 units in size you would simply check the position of your camera ship, the position of the enemy ship and if they come within 50 units of each other (half the ship size as measured from it's center axis) then a collision has taken place. It isn't polygon level accurate but then neither are the box, sphere collision and you won't end up with overlapping objects.

http://www.canceriannewmedia.com
HoverFrog
21
Years of Service
User Offline
Joined: 7th Aug 2003
Location: Canada
Posted: 17th Oct 2003 03:50
Thanks for your reply Knau, I guess that would work but my ship is a rectangular box kinda, much longer than the width or height so a proximity check from its center would be realy not precise, I tried with other models (from the Dark Matter library) and all the collisions work fine. I must have done something wrong when designing my ship on 3D Canvas, which is something I am also new at...
ESC_
21
Years of Service
User Offline
Joined: 29th Aug 2003
Location: Mass.
Posted: 17th Oct 2003 05:25
You can use simple math for rectangular collision checks as well, and it would be MUCH more effient than any built in collision. For rectangles, the key is using absolute values. For instance, say you want to check if the two x coordinates are within 2 units of each other, and if the y is 1 units, and the z is four units. All you would need to do is:
if abs(x1-x2) < 2
if abs(y1-y2) < 1
if abs(z1-z2) < 4
{stuff goes here}
endif
endif
endif

"That's not a bug, it's a feature!"
"Variables won't, constants aren't."

Login to post a reply

Server time is: 2024-09-21 06:20:21
Your offset time is: 2024-09-21 06:20:21