S
S
SDHOPS2018-05-09 20:03:10
C++ / C#
SDHOPS, 2018-05-09 20:03:10

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.
5af328922c001734142985.png
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.
5af32973266ea567288296.png
The event is stopped, the function is selected;
5af329b313f19385538963.png
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:
5af336b86646e045158775.png
I hope you understand why the code is written in Character.cs, and on the Player.cs, I am making an NPC.
5af3371e74646001591638.png
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):
5af337e0d8b9b575837897.png
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

1 answer(s)
S
SDHOPS, 2018-05-09
@SDHOPS

Kill it, it worked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question