Trigger on two static players (collider 2D)
Hi,
I'm stuck on a collider trigger issue. I have got 2 players which can attack eachother, with boxcollider2d on both of them. They have a melee weapon (with a boxcollider2D too, as a trigger), that is enables when a player push the attack button. They get hit well when one of the two players is moving.
But when both players are perfectly still and hit each other, , the ontriggerenter2d won't trigger
My weapon script :
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag("Shield"))
{
SendMessageUpwards("Counter");
}
else if (col.CompareTag("Player"))
{
col.SendMessageUpwards("Hit");
}
}
I also put a shield on my players, with a boxcollider as a trigger. Same issue with them.
Have an idea?
Thank you!
Hello,
I found a way around by moving the character a tiny bit when I attack.. Dirty but works like a charm.
I am trying now to make my sword attack moving forward ins$$anonymous$$d of just teleport in front of my character, it should do the tricks too and I am trying to make the attack canceled only when I hit the opponent shield first and only then.
In my code right now, if I attack someone by behing and hit a pixel of the shield, it is considered like a counter.
Your answer
Follow this Question
Related Questions
Need to move gameObject when triggering collider 0 Answers
Calling "OnTriggerEnter" when a parent object has a rigidbody 0 Answers
Does not contain definition of isTrigger? 1 Answer
Make Blocks stay in the grid 0 Answers
2D Collider Problem 1 Answer