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 Professional Discussion / How can you tell what's in front of you?

Author
Message
Jaidex
22
Years of Service
User Offline
Joined: 28th Jan 2003
Location:
Posted: 6th Feb 2003 06:25
Is there a way to tell what's "in front" of a player for the purposes of firing weapons, etc? To explain, if I want the player to fire let's say a laser at whatever is directly in front of him / her, how would I check to see what the laser hits? I'm guessing that there MUST be a way to check this kind of thing (what lies along a path) without actually moving an object along that path to see if it strikes something... Er... I hope!

Thanks for any help!

Jai
Bangla
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: Sweden
Posted: 6th Feb 2003 12:14
That is one way of doing it, quick and easy. DBP has it's own way of dealing with line-of-sight, look it up in the manual.
Or you could have a long, thin hidden box extending out from the player at all times and checking the boundingboxes for collisions.
Or you could use maths to see if the line of sight from the player cuts though the radius/box of the object.(Although I never got that to work, I've seen it used extensivly. Look up the formula in a mathbook or see it here: http://astronomy.swin.edu.au/~pbourke/geometry/sphereline/ )

Or you could use pythagoras theorem to work out the angle between the player and the object. The last one I've used before and it works... kinda.

400 Mhz, 120 Meg, TNT2 - and then some...
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 6th Feb 2003 16:33
you can tell the angle between two objects with atanfull()
Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 6th Feb 2003 17:52
the INTERSECT OBJECT command can help here

NOBODY has a forum name as stupid as Darth Shader. I do.

Login to post a reply

Server time is: 2025-05-20 04:49:06
Your offset time is: 2025-05-20 04:49:06