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 / How to detect the object I collided with?

Author
Message
Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 8th Jan 2006 21:38
How is this done? I've tried using a variable like so

but it says "Object Number Illegal at Line 63" where my function SlidingCollision() reffers to it's argument "w".

What's the best way to check if I'm hitting something, and if so, retrieve the object number of the object I collided with?

Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 9th Jan 2006 02:21 Edited at: 9th Jan 2006 02:22
there doesn't, seem to be anything wrong with the code you have unless at one point plr = 0 but id have to see the sliding collision function if you say your problem is at a line withen it.

Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 9th Jan 2006 19:49




Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 10th Jan 2006 02:41
there doesn't seem to be anything wrong with your collision but the only two things i can think of would be instead of
IF OBJECT COLLISION(PLR,w)
try
IF OBJECT COLLISION(PLR,w)=1
i dont know if it will help but other then that as far as i can see the only other thing is if at one point w = 0

Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 10th Jan 2006 14:03
Is the variable PLR declared as global?
If not PLR will always be 0 within function.


The word "Gullible" cannot be found in any English Dictionary.
Image All
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: Home
Posted: 11th Jan 2006 08:20 Edited at: 11th Jan 2006 08:36
Haven't been here in awhile

Thnx for your answers, I figured it out and took Flashing Blade's advice and turned all meh variables into globals

Here is the working code:


Just add SlidingCollision() to your main loop and change PLR, PLRX# and PLRZ# into the variables representing your player's ObjectNumber, ObjectPositionX and ObjectPositionZ respectively.

/me tests with a cylinder...
It crashed

Login to post a reply

Server time is: 2024-11-27 07:53:48
Your offset time is: 2024-11-27 07:53:48