How do I make a melee attack without damaging the player character?
I want to make a game where the goal is simply to defeat the other player by melee combat. I have characters and I have attack animations, but I don't know how to make my character's attack cause damage to the other player without inflicting harm to themselves. I tried putting the health modifier onto the sword of my character and set it to impact mode, which didn't work. The health tutorial did not cover how to deal damage in the form of an attack.
What steps do I need to make so that the melee attack only damages the second player?
Bonus questions:
* How would I set up a "block" logic to protect against incoming damage?
* How would I set up an NPC (to attack the player)?
* How would I make a character select screen?
Thanks!
-
I will cover your primary question:
Using labels is great for that. You can set which label should be detected and work from there. So if your sword detects only "foe", the health modifier inside the sword will only modify the health from the object with the label "foe" as well. You can then choose if it should be based an a hit detection or zone. -
Thanks! But would that work also if I wanted to add a second player to the game? Because then how would my sword know which player is the foe? Both player's can't be tagged as Foes for this method, right?
-
One is "Friend" and one is "Foe". That should do it
-
How about if I want to have many characters? It seems like the health manager only has a few options for labels, I would eventually have to reuse labels, e.g having two characters labeled as "friend", which would make them unable to attack eachother?
-
You can also use tags for multiple different characters
댓글을 남기려면 로그인하세요.