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 / Need help with collision

Author
Message
TheWhite
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location:
Posted: 8th Jul 2003 09:08
I am trying to make a 3d-asteroids game the only major problem I have is how to get object collision to work.
I have used a sphere to get camera collision with my walls/asteroids with the folowing code:

For x = 1 to 6 (the walls)
if object collision (x,7) > 0
code to get camera back to where it is supposed to be
endif
next x
For x = 10 to 16 (the asteroids)
if object collision (x,7) > 0
code to get camera back to where it is supposed to be
endif
next x

and this by itself works fine. The problem comes when I try to get a bullet to hit an asteroid. I have used the following
For x = 10 to 16 (the asteroids)
If object collision (x,9) > 0 (have also tryed 9,x)
do stuff
Endif
Next x

What happens now is that neither the bullet nor the camera object will hit the asteroids unless BOTH of them are hitting at once in which case only the bullet part of the code will work.
Can anyone help me pls
Xeridox
21
Years of Service
User Offline
Joined: 19th May 2003
Playing: Scrap Mechanic
Posted: 8th Jul 2003 09:28
First off, change your collision commands to
if object collision (7,x) > 0

if object collision (9,x) > 0 is the way to get it to work

I don't see any other problems, I need more of your exact code to help I'm afraid.

IRC Channel: #darkbasic on server irc.uk-net.org Ports 6667 or 6668. Helpers and game serves welcome or just come and chat!
TheWhite
21
Years of Service
User Offline
Joined: 22nd Jun 2003
Location:
Posted: 8th Jul 2003 09:43
Why does it matter which way around the numbers are? I have tried with them both ways and neither helps

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2003 19:02
assuming your bullet is object 9 then it should work either way round, it doesn`t matter if the bullet hits the asteroid or the asteroid hits the bullet, same result, the problem must be in the later code, esp since it is affected by the camera too, I dont even know why you would want the camera collision enabled for that type of game, and at the start where you keep checking objects and putting the camera back, why?, whats moving the camera?, as I say to most new coders, your code won`t be something awesome and innovative thats gonna be stolen by everyone on the forum to make their fortunes ,post more of it and we may be able to say where you are getting the problem, mind you, it`s a vast improvement over some posts (like the infamous "SHOW ME DA CODEZ"), cheers.

Mentor.

Login to post a reply

Server time is: 2024-11-24 20:31:36
Your offset time is: 2024-11-24 20:31:36