Damage with melee weapons


I’m working on a game where a character uses a staff. My question is,
what do I have to do to make the staff inflict damage only when swung?
Do I have to join meshes with the weapon and the character? Are the weapon and the character supposed to be separate objects? I’ve never done anything like this before so please fill me in.

Thankyou. :smiley:

For the bounding options for the staff, choose ‘ploytope’ and the game engine will use the shape of the mesh for collision detection instead of a sphere or box. Then add a property to the staff like ‘staff’ or ‘weapon’ and add to the enemy AI a collision sensor that reacts when colliding with an object possesing that property. Hope this helps!!!


Your method works, but when the staff isnt swung, enemies can still take damage from just collision…

If you want damage to be inflicted only when swung, after you add the two sensors ( Keyboard, and Collision ) make an And controller type and connect them both to it…

This way the damage will only be taken if you swing AND come in collision with another property…

oh yeah, thanx… didn’t even think about it… :wink:


Great help, guys. :stuck_out_tongue: I’ll try it. :slight_smile:

Wait a minute. By using Keyboard and Collision sensors, you make it so that it’ll only damage if you’re still holding the key down, so if you let go too early, nothing will happen. What I do is use a Timer property. When the key is pressed, it goes to -1 or something. Then I have the Collision linked with a Property sensor that only activates when the prop is between -1 and 0.

Ok, I think I’ve got it. I just need to know one more thing.
How should the staff ‘be’ in the character’s hands. Should I join the staff
mesh and character mesh together? How do I animate the staff while it’s in the characters hands if it is supposed to remain it’s own object?

Thanks again. :slight_smile:

Would parenting the staff to the character work? You could parent the staff directly to the bone in his hand if you are using 2.37 or later (its broken in earlier versions.

Hmmm . . . unfortunately, I’m using 2.36. Perhaps if I downloaded
2.37 or higher. But before I do that, there’s something I’d like to know.
Last time I downloaded a higher version of blender it overrid all my work.
Should I save my blends on a diskette and then download 2.37?

What do you mean by your work being overriden? Nothing should happen your existing blend files unless you specify in installation to open the files in that version of blender. Blend files should work in all versions of Blender although different versions of Blender might give you different results if the features you use were implemented differently in the different versions.
I suggest you download the version of Blender located here because in the normal 2.37 release, the mouseover sensor is broken and this version includes a few game engine specific features.

Hmmm, interesting. I remember when I switched from 2.34 to 2.36
all my blends appeared to be gone, as if the whole blender thing started
over . . . I lived with it of course, but anyway.

Well, I was able to parent the staff to the character’s armature and
assign the vertices in it the the character’s hand. So far it works
pretty good. :slight_smile:

I will keep that download in mind though.


Hmm, it seems I’ve come across another problem.

When the character moves forward the staff is supposed to follow her.
Which it does, as I partially solved in the game logic. But now when the
character runs forward the staff seems to yaw out of her hand.
I’ve checked the problem at it seems to be in the motion actuators.
The staff’s motion actuators correspond to the character’s when she moves forward, and I’m not sure how its yawing.

Hmm, would anyone know how to fix this?


Why does the staff have a motion actuator if it is parented to the character? It should move with the character because of the fact that it is parented.
I knew about the workaround of parenting all the vertices to the bone but I didnt suggest it because it doesn’t produce the best results. The yawing might be because of this as well.

Ok, I’ve downloaded 2.37 and I have my character and everything! :stuck_out_tongue:

I need help with two things.

First is I would like to know the proper proceedure for parenting the
staff to the bone in my characters hand, as you mentioned earlier,

Second, when I start the game, there are two of my characters instead of
one. One’s higher than the other and facing the other way. I found out
there were multiple objects for my character that I had to delete and this
seemed to help, but I still get another character flickering on the screen?
Does anyone know what’s wrong?

Thanks guys. I really appreciate the help. :smiley:

Select the staff then hold shift and click on the amature. Press CTRL+P and click Bone. Then select the name of the bone in your characters hand.
As for the flashing second character, be absolutly sure theres only one copy of your character. Thats the only possibility I can think of.

Thanks, I got it.

There are a few problems though. I made absolutely sure there were no
copies of my character and the double-character thing still shows up . . . :-? It seems it shows up especially well when I start the game in wire mode. I’m thinking the copies of the character weren’t it at all. . . .

Also, when I make the character walk, the staff follows her, but it can’t seem to stay in her hand. Its going up and down uncontrolably. When I make the character stand still it gradually bobs back into place.

Hmm . . .

i’ve made a few games with with “hand to hand combat”, and i’ve come across the same problem.

in blender 2.25, the collision detection of a mesh like a sword does not move once parented to an armature, even though it appears to be moving in animations

use edit object, addobject to shoot an invisible mesh forwards for a small amount of time, to similate a forward punch

for swords i used edit object,add obj an invisible rectangular prism about the shape of the sword and have it play an IPO animation as soon as it’s added. this IPO animation can simulate the swords movements/swings

lol, i know they arent that great, but hopefully you find it helpful

Thanks, but I’m not sure that was absolutely clear to me.

Let me make sure I understand . . .

You select the staff, add a new object, like a rectangular prism, then parent prism to the staff(?) and then make an ipo animation to make it’s movements look right?

Ok, a little more information.

The double-character effect is fixed.:slight_smile: It must have been the camera. %|

I’ve done some experimenting and it seems that the staff bobbing up
and down might have something to do with the motion actuators.
When I don’t assign the staff any motion actuators it doesn’t move
forward with the character, but it doesn’t bob up and down either.

. . .

Eurika!!! :stuck_out_tongue: (If that’s how you spell it).

I’ve developed the perfect solution! Assign the motion actuators to the armature instead of the character! Everything works now!

Well, for I now . . . (lol, little humor there)

Thanks guys for all your help.