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 / Melee Combat

Author
Message
Wasteland Seraph
15
Years of Service
User Offline
Joined: 1st Sep 2009
Location: Benton, Arkansas
Posted: 5th Sep 2009 18:21
I'm working on a 3D FPS, just to clarify

I may just be blind as heck, but I cannot for the life of me find a tutorial or example of how I would go about adding in melee combat to my game. I'm not concerned with the animations and models at the moment (as it does me no good if it doesn't work in the first place), I'm just trying to add in a system of "Click - Swing Weapon, deal damage within x feet in front of the crosshair"

Can anyone demonstrate or help me with a link?

Your signature has been erased by a mod - Please reduce it to 600x120 maximum size
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 5th Sep 2009 19:37
You would need to do something like this:



That's not actually code I just came up with that but that's how I would probably do it... I'm pretty much still a newb. Since no one else was posting though

ßõw§€r¥¤
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 5th Sep 2009 20:03

Bad idea, Bowser! ^_^
You can't compare the X difference and the Y difference seperately, or you could hurt enemies halfway across the map who just happen to be within 5 units of you on one axis.

Also, with your code, you'd kill all enemies behind you!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
BowserYo
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location:
Posted: 5th Sep 2009 20:52
Oh well

ßõw§€r¥¤
Wasteland Seraph
15
Years of Service
User Offline
Joined: 1st Sep 2009
Location: Benton, Arkansas
Posted: 6th Sep 2009 15:40
Could I have you elaborate? I'm thankful for the code example, but could I get a little more direction with the specifics?

Wasteland Seraph
15
Years of Service
User Offline
Joined: 1st Sep 2009
Location: Benton, Arkansas
Posted: 21st Sep 2009 02:13
Is there anyone who might be able to explain this in a little more detail? I haven't been able to find anything helpful pertaining to melee combat, at least for a FPS in DB Pro : /

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 21st Sep 2009 02:27
Look at Dream and Death's code.

It takes the distance from your player to your enemy. If there is a mouse click in there, it checks the distance and if its less than the specified value, then it hurts the enemy. You would just have to write a function Damage_enemy() on however you want to do that. Play around with what they gave you.

Wasteland Seraph
15
Years of Service
User Offline
Joined: 1st Sep 2009
Location: Benton, Arkansas
Posted: 21st Sep 2009 02:46
Dream and Death...? I tried a forum search, but I'm not sure if you meant that as a project, the name of a user(s), or what.

FireIndy
17
Years of Service
User Offline
Joined: 17th Jan 2007
Location: US of A
Posted: 21st Sep 2009 02:52
He posted 4 posts above me. Just play around with that.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Sep 2009 14:59
You can always use normal collision too.
More advanced, you could use hit boxes to actually detect where the hit landed...

Sven B

Login to post a reply

Server time is: 2024-11-25 01:43:32
Your offset time is: 2024-11-25 01:43:32