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 / collision problems when using 'fake' bullets

Author
Message
greg man
21
Years of Service
User Offline
Joined: 6th May 2004
Location:
Posted: 16th Jul 2005 20:05
Sorry if this topic has come up before but i couldn't find it on a search.
I have been trying to make an fps game without using actual bulets. Instead i am trying to use a long thin cylinder that is projected from the gun to detect when the enemy is hit. however i have not been able to detect collisions between the cylinder and a cube that is acting as an enemy. Can someone please tell me what i am doing wrong and help me out please. The source code so far is here. It's probably something really stupid that i've just over looked so any help would be appreciated.
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 17th Jul 2005 00:10
First of all use a long rectangular prism for that collison, it's faster since there's less polygons.


You don't seem to have much source code to work with either:


Is that a forum bug?

Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 17th Jul 2005 01:12
Yes that's a forum bug. It often happens with new ppl

Immunity and Annihalation makes Immunihalation...
greg man
21
Years of Service
User Offline
Joined: 6th May 2004
Location:
Posted: 17th Jul 2005 02:36
Sorry about the code being missing here it is again. I havn't had time to change to a cuboid yet but thanks for the tip

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Jul 2005 03:39
aha, i know what u mean, ive done this before with an FPS, I started off using a cylinder and wanted it to collide with any enemies, but then i found a better solution.. here's how

say you have 10 enemies, then make 10 plains, 1 plain per enemy,
position these plains at the player and make each one point to its corresponding enemy, and if you are roughly at the same angle as say plain number 6, then that means you are pointing at enemy number 6, then you can shoot it...



Your signature has been erased by a mod because it's larger than 600x120...
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 17th Jul 2005 08:02
greg man,

Have you thought about using the raycasting method?

Raycasting is a quite simple method of checking each point(a point being a position in 3d space) between two specified points. Specified point a would be where the weapon or character is located(where the bullet is shot from), and point b would be where the bullet would end up at it's end(the distance it can ultimately travel).


+NanoBrain+
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 17th Jul 2005 08:24
..Basically, rather than using 3D objects that have to go through DarkBASIC and back again, NanoBrain's method just involves Math. S.

How's my typing? Phone 0800-GO-TO-HELL
greg man
21
Years of Service
User Offline
Joined: 6th May 2004
Location:
Posted: 18th Jul 2005 00:52 Edited at: 18th Jul 2005 00:54
Thanks for the help guys. I'll try both of these methods to see which one works best for me. With the raycasting method, wouldn't it slow down the game alot using massive for/next loops or is there a better way to check each point?
PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 21st Jul 2005 04:04
You could try generating points along a line which would be in the path of the bullet. If one of these points lies in/on the boundry of an object then that object has been hit.


Just an idea

Always available to help
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 21st Jul 2005 05:29 Edited at: 21st Jul 2005 05:36
As stated by Nano raycasting is very efficient, take a look at The Newcommer's Guide to First Person Shooters for info on how to do fast bullet calculations. It covers a lot of things about shooting, but isn't finished. At it's current state however their is the basics of detecting if an enemy is infront of you and if they are it reduces health as the mouse is clicked.

Here's the link: http://forum.thegamecreators.com/?m=forum_view&t=56770&b=7

As said it's still being worked on but is very helpful at it's current state.

P.S: About the for/next loops cutting down your speed. Well it would unless you program it not to

Using some simple removal process can easily speed up the program. Things like:

- Only using the loop if the user has ammo, or even a gun
- Only using the loop if their are enemies in range or enemies alive
- Skipping dead enemies inside the loop

There are lots of other ways aswell, look for JessTicular's post on that.

<EDIT> DOH! Just realized this is in Dark Basic discusiion and DB users dont have intersect object, my bad.


Current Projects: SHADE - Game Maker | Mecho - TGC Puzzle Entry | Halo Physics Engine | COLD - Polygonal Collision Detection
greg man
21
Years of Service
User Offline
Joined: 6th May 2004
Location:
Posted: 25th Jul 2005 00:20
Thanks for the help guys. I was just thinking of zotoaster's idea because at first i thought it wouldn't be very accurate because you get a 'hit' if the angles are within 10 degrees of each other no matter how far away you are. I was thinking that there must be a way to calculate the level of accuracy needed to score a 'hit' based on the distance mathmatically if only i was smart enough to work it out. If there is a way it would make this method of doing bullets quite accurate and efficient. Any ideas?

Login to post a reply

Server time is: 2025-05-22 12:57:24
Your offset time is: 2025-05-22 12:57:24