Game Development Community

Melee weapon

by Jonas · in Torque 3D Beginner · 06/09/2010 (2:57 pm) · 4 replies

Hey again guys.

So i got everything regarding guns down now switching to one another ammo and everything so i am moving on to a melee weapon.

My question is basically how do i go about making a melee weapon a part from a shooting weapon? The thing that eludes me is how do i make it dmg someone? since its just a swing do i need to add a effect to it or something?

i know how the entire animation lapse should be setup its just the dmg part i dont get.

Note: Please make references to code that already exist if that is possible thus far i am not that skilled in writing code from nothing.

About the author

Freelance 3D artist at day scripter/coder on Enduring Life at night. Lover of all things TorqueScript.


#1
06/10/2010 (12:46 pm)
There are a few different ways to have a melee weapon cause damage.

One method is to write some code that checks intersection of collision volumes - one for the weapon and one for a target. This can incur overhead since the movement of the weapon would entail that the location of it's collision volume is updated across the network.

An alternative (commonly used) is to simply fire an invisible projectile that has a short live time and distance traveled. This dummy bullet is what would cause damage, and the movement/animation of the melee weapon would simply be eye-candy.

Similar to the dummy bullet method is to make a raycast to check for something in range. If there is something within melee range than applyDamage(). Again, the weapon animation itself would just be eye-candy.
#2
06/11/2010 (10:51 pm)
Ah i see. I think i will go with the invisible bullet thing sounds to me to be a easy way to get a precise melee weapon.

Best regards
Jonas
#3
06/15/2010 (2:20 am)
You can also raycast along the damage-dealing part of the weapon itself, as a sort of half-way solution between the third and first propositions Michael listed. I'm not entirely sure how easy this would be to do in script, is the only thing (T3D may have changed from TGE in this regard).

Also, another dummy method you might consider is doing a radius-search around your character, and doing damage to anyone within a certain arc (multiple attackers could be hit).
#4
06/18/2010 (2:18 am)
There is a nice resource by Sean Rice about this.

http://www.torquepowered.com/community/resources/view/19509