Answer the question
In order to leave comments, you need to log in
Why doesn't "Enemy" take damage from the specified EdgeCollider2D?
I changed the version of the question, in the first version the question was not quite correct. EdgeCollider2D works, everything is correct, it's just that the Enemy does not take damage from EdgeCollider2D.
The code is next.
Here is the complete code.
https://pastebin.com/ytF2gGf3
This image shows that everything is enabled as expected, the tag is selected, the collider is disabled, selected as a trigger.
The event is stopped, the function is selected;
We have verified that EdgeCollider2D works. In the above code, it was seen that it is possible to specify the Tags from which Enemy should take damage (see line 20, 56). As you already understood, the EdgeCollider2D component hangs on an empty GM (SwordCollider), which in turn hangs on the "Player". The player has the Player tag, the SwordCollider has the Sword tag.
In the inspector, the Tag from which Enemy should take damage is selected:
I hope you understand why the code is written in Character.cs, and on the Player.cs, I am making an NPC.
Enemy won't take any damage from my EdgeCollider2D trigger at all until I choose my own weapon in the NPC itself (Enemy.cs uses Character.cs as well as Player.cs):
In this case, Enemy will take damage from weapons with the "Sword" tag ', and everything seemed to be cool. And here it is not. That's not how it should work. I shouldn't specify my weapon in Enemy, he should already take damage from my weapon, because I specified it in my Player after all, you saw.
And in general, even if it works, it is not the way it should be. Enemy takes damage not from the EdgeCollider2D trigger, but from an object with the Sword tag. That is, as you remember, the empty GM SwordCollider has the Sword tag, and if I stupidly come up and touch Enemy with this dummy, then he will receive damage just like that.
I ask you kind people, save me, help me. Sorry for such a sad story of one unfortunate NOT programmer. Plak.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question