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 / fps shooting question

Author
Message
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 12th May 2006 07:49
I am makeing an FPS(like the subject didn't give it away). I am trying to find a FAST but EFFICIENT way to check for collision with the bullets. Moving them one space at a time takes too long. I am sure that someone has figured this out now, so, any ideas? BTW, I am using DBC.

Thanks in advance
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 12th May 2006 08:37
Yeah, i got the same Question,but im using DBP and i just start the envirement(If my old Version dont crashes...)

Your signature has been erased by a mod because it's larger than 600x120...
Mr X
18
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 12th May 2006 13:23 Edited at: 12th May 2006 13:24
Im using dbpro, so I dont know if it will work, but why not make a FOR-NEXT loop there you move the bullet once, check its collision, and repeat that until the loop runs out? It would look a bit like this in dbpro (its not a tested code):


If you check collision like this: "object collision(nr,0)", it will return the nr of the object it collieds with. At last in dbpro.

Hope it helps.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th May 2006 14:31
Think about it, you never actually see a bullet in real life, so what's the point in even making one in DB?

If you have DBPro check out the Intersect Object command, if you don't have DBPro, check out Sparky's collision DLL.

Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 12th May 2006 16:59
I got DBP,old but i got one.

I cant seem to find out how to get it working though.

Your signature has been erased by a mod because it's larger than 600x120...
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 12th May 2006 17:49
The "pick object" command works well for when the player is shooting in first person shooters. The only problem is that you won't be able to use it for when the enemies are shooting.

Insanity is just a state of mind
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th May 2006 01:04 Edited at: 13th May 2006 01:06
Master mind: I tried that, but it takes a long time for the bullet to complete its motion. If the range is 500, the player is left watching a frozen game until the bullet has moved 500 times, approx 30sec to 1min

Daemon: Is that a DBC or DBP command?

Zotoaster: I looked at the thread for that dll, is it only for DBP. Thats what it seems like
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th May 2006 06:11
I found a way to do it, but it does make the game lag a bit when you have the mouse key held down. Any Ideas on how to fix this?

Here is the code for the shooting/collision detection


basically what this does is

A.)Creates a box from the player to 1000 units ahead of player(in this case the range is 1000)

B.)Checks for collision with objects & the bullet(box)

C.)Determines which object being collided with is closest to the player(distance formula).

D.)Passes the number of the closest object to the player_hit subroutine(which at this point just makes the object that is hit turn black).
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 14th May 2006 22:46
Zoto already gave you the answer

If you're using DBP, use the Intersect Objet command. If using DBC, get Sparky's Collision dll. This command will return when a 3d vertex is inbetween two points in 3D space. As the great god of toast said, bullets move so quickly that theres no need to make an object to show them, it will just lag the game up. Instead, you check for intersection with every enemy object using an intersection ray starting from the user's position, and ending at however many units infront of the user you want. If an intersection occurs, the command will return the distance to the object hit, using this information you can first check if the user is clicking, and if so then check if an object is intersecting the user's path of sight using either the Intersect Object command or Sparky's Collision dll. If the return is true, damage/kill/rape the enemy being shot, otherwise dont do anything.

Its much more efficient, easier to implemenet and more practical than creating and maintaining hundreds of bullet objects.

However if you must use 3D objects (perhaps for slow moving things like rockets...or you just dont understand what I said above and are still going to try and use objects instead, then heres what you do)

1. Determine the range of the bullet

2. Determine the Z length of the bullet object

3. Determine the speed the bullet will be moving at

4. Divide the length of the bullet into the range to see how many bullet objects you need.

5. Create a currentBullet variable to store the current bullet objectbeing used.

6. Hide all of the bullet objects

7. If the user clicks the mouse...

8. Position object currentBullet at the user's gun position, and
rotate the object to the gun's rotation

9. Show the bullet object

10. Using a for/next loop (this is outside of the mouseclick check), giving the loop a start value of 1 and an end value of however many bullets you created. In this loop, if for example the loop variable is called i, check if object i is visible, if so it must have been fired in which case move it forward. Also check for collision.

11. If a collision occurs hide the object, this will stop the loop from moving it.

Ofcourse using an array for the bullets would make this a lot simpler, and adding in types would make ti even better. You could get into using things like IF Bullet(1).Fired = 1 THEN Move Forward, etc.

Anyways, Id still highly recommend looking into the previous suggestion with intersect object command.

- RUC'

Login to post a reply

Server time is: 2024-09-24 23:25:30
Your offset time is: 2024-09-24 23:25:30