Melee Combat

Hello, im making an rpg and having trouble making the melee combat system. Ive tried making it so when player attacks a bullet type object is added in, which enemy detects with collision and minus appropriate amount of health. For some reason, the enemy never detects collision with the object added in. Is there something im doing wrong, and also, is there any other way to do a melee combat system.

THANKS for any help!

maybe you can have the weapon detect vector (x,y,z cooridinates), and if the vector is within range of the target, it can detect a hit. But I’m unfamiliar with this, I’m a Crymoder

Im not sure how you would do that in blender or even if its possible. Thanks for suggestion but does anyone else have any idea?

Well if your “melee object” (sword/staff/whatever) is a seperate object from your character AND is animated via an IPO, you should be able to detect collision on that object. Just give it a property (say “hurt” or something) and then have the enemy detect it.

The trick would be to make sure that it doesn’t trigger over and over again… which really wouldn’t be too hard. Just increase the time between pulses on the sensor.

-Sam

Okay. This is what I do:
In front of the player, add a box with the property ColBox. Make it a ghost object.
When you attack, make it so that it sends a message called Hit.
For the enemy, have a Collision Sensor set to ColBox and a Message Sensor set to Hit and attach them to the same And Sensor. In the actuator, put in the thing that takes away health and Whalaa!

Ok redhand, i had a similar setup to what you said, so i decided to try your idea. The message works, but for some reason they’re not detecting collision. Is there anything i could be doing wrong?

Hmmm, not detecting collision… All I can think of is that you disabled collision on your bounds instead of making it a ghost object or that for some reason the thing detecting the collision doesn’t have it enabled either. You cannot have the reliever of the collision be an empty. Those just flat out don’t receive collisions.

I don’t understand, it works with sumo physics, but when i turn it to bullet it doesnt work. Is there a difference between bullet and sumo?

I believe so. I think Sumo is deprecated. I’m not exactly sure what that means, but it’s probably old and unused. Bullet is the default and is probably the more suitable, stable physics engine.

That still doesn’t answer why it works there but not in bullet. I just want to get this working so i can countinue working on my game. I’ll post a blend if you want.

are both the objects actor and dynamic.

Yes they are both actor and dynamic, do you think you could make a quick blend? If you can’t just say so and ill post my blend. I would post my blend earlier, but its a WIP and i want to show it when its in better state.

Use Physics visualization in options in Game menu and test if all its colliding well. Use Control +A with the objects for avoid problems.

Okay. I’ve put a little blend together for you. The Wireframe box is your Collision Box. When it touches the enemy, press space to attack it. You can see the enemy’s Health under the debug properties. The enemy can go into negative health only because This is a demonstration how to do melee, but not the whole character enemy setup. Enjoy and ask questions as needed.

Attachments

Melee Attack.blend (142 KB)

i was making a sword finghing game a few weeks back n i found best way for me was rays detecting when player is close or far from opponent, thus if the “hit” message would be sent seems to work ok,also a timer set to the attack animation so it only hits when between certin frames idd post my blend but not sure how o0

OK, i think ive narrowed the problem down, i dont think it has anything to do with collision. Its a weird problem. When ever I parent my collision box to my character collision stops working. If i unparent it, it works.

Interesting…

If it will help ill post a blend tommorow, i got to got to bed now.

Here is the blend. http://www.mediafire.com/?mv3ytaly2l9