Unity 2D trigger richtung abfragen (oben, unten)?
Hey, bin gerade dabei einen Plattformer zu erstellen 2D, und würde gerene bei meinem Gegner so einstellen, das wenn der Player den Feind von oben berührt (egal ob mit Trigger oder Collider) dann soll der Feind Zerstört werden. Wenn ich den Feind von unten oder den Seiten Berühre soll der Spieler Zerstört werden (Leben abgezogen bekommen)
Ist es möglich einen Trigger auszulösen von einer bestimmten seite, oder so was ähnliches ?
Danke
Hello,
there is certainly a more elegant way to solve this, but I would spontaneously find the solution that you will check with a script based on the opponent’s height as well as the opponent’s position and the ground if your player’s Y coordinate is greater. If so, kill opponents. If no, kill players.
I hope I could help you.
Yes I have not found a better solution so far. It is important that you somehow calculate this with the size of both colliding objects so that you can use the script in all possible objects.
Exactly
I would have placed an invisible object with collider subordinate above the opponent and then programmed that in collision the opponent is destroyed
Hope that could help