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 / Unbelievable

Author
Message
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 24th Jul 2005 04:22
I use DBC, enhanced and updated version. I have an X file model from DarkMATTER that I use for my game, and he has a gun built in with the model. In Lucifers name, does anyone on this forum know how to do raycasting from a gun to make a bullet that will collide with other X file Models? I searched everywhere, even on google! Nothing! Despite how much I hate begging, Please reply someone!

-Xeno
waffle
22
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 24th Jul 2005 04:50
DBC has nothing that will automatically do that for you. You will
need to code it. Generic code for such a thing is also hard.
Each game has unique problems and different objects that may or may not need checking. In the code base, there is a raycast thingy for DBPro ... if you use something simular, and use a fast range test method instead of intersect object, you should be able to come up with something.

Another problem you'll have that will cause a problem is the gun location. There is a function for getting the real world position of the gun, but again, its not generic, and require knowedge of the model ... limb number of the gun. Another method would be to use collision offsets and manually adjust for gun location. A quick and dirty hit check method would be:

1 - place camera at gun location (use offsets for location relative
to the actual model)

2 - determine range to target (need precision for this)

3 - place bullet at camera loaction
4 - set bullet to camera orientation

5 - move bullet "range to target"

6 - check collision by whatever means you desire

7 - move camera back to "normal"

To check for obstructions along the path, you will need to move the bullet along the path and perform checking along the way ...
That's your ray-cast algorythem ... Its not complicated, just tedious and time consuming. In the example in codebase, this check
was only performed during an actual shot, to keep impact low.
Also, depending on level complexity, you can optimize by not checking all objects, adjusting bullet move distances ... and so on.

Another example of how to do this is in the Iced Demo.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 24th Jul 2005 05:41
Thanks so much waffle, I can't believe I forgot about the Iced Demo...

Login to post a reply

Server time is: 2025-05-22 21:31:24
Your offset time is: 2025-05-22 21:31:24