- Home /
Melee Combat
Well I'm kinda new to Unity and i am trying to make a Melee combat system... I'm completely lost through. I know i could make a reeeeaaaly simple melee combat system (get in range, press a button), but i would like something more... sophisticated. I mean, it would be awesome if the opponent would only take damage when the sword (or whatever) actually touched the opponent's collider. Well, i hope you guys can help me!
P.S. Please don't just link me to the documentation or give a really vauge answer... Also, i prefer C# over Java, because I can understand C#, and I don't understand java.... at al....
To do what you described wouldn't you just place a collider on the sword (or whatever weapon) and then check to see what it hits when the user attacks? I$$anonymous$$ Sword hits enemy torso collider -> do damage, sword hits shield collider -> do no damage.
Sorry if I'm misinterpreting the question.
"P.S. Please don't just link me to the documentation or give a really vauge answer... Also, i prefer C# over Java...." --
This just tells me your lazy. You're asking people to develop this, in your words, sophisticated, system. Give me a break, beggars can't be choosers.
Answer by doublethink · Jan 16, 2013 at 08:52 PM
What you are asking for is an extremely complex system even with just the basics. Your best bet is to make a system based on a box collider(the sword) and rigging the players(rigidbodies) with box colliders(think hitboxes) that can report to the parent player object where the player was hit from and what it was hit by. To make it look realistic you could apply force using Rigidbody.AddForce to the player that was just hit.
I know you requested "Please don't just link me to the documentation". Instead, I will give you MANY links to documentation. It sucks but you will need to read much more than just these pesky documentation pages to get anywhere in Unity game development.
http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.html
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
I'm almost done making the damn thing. $$anonymous$$an, that was a LOT of work.
Oh, and I still have to thank you for your answer. Well, ehh, Thanks.
Think about making a tutorial for us then? :-) Exactly what you were looking for in the first place?
Your answer
Follow this Question
Related Questions
Melee attack comblat 1 Answer
Multiple Cars not working 1 Answer
How can i detect collision in melee combat? 2 Answers
Sword Combat System: Detect if player in range 2 Answers
Multiple Melee Weapons 2 Answers