So, I’ve set up a pitfall in my game that has a trigger collider. The player has four directional colliders at their feet to determine which way they fall to make it look like they fell into the pit.
if (!didFall)
{
switch (collision.gameObject.name)
{
case ("TopFall"):
didFall= true;
playerAnimator.Play("Player_TopFall");
print("top");
break;
case ("BottomFall"):
didFall = true;
playerAnimator.Play("Player_BottomFall");
print("bottom");
break;
case ("RightFall"):
didFall = true;
playerAnimator.Play("Player_RightFall");
print("right");
break;
case ("LeftFall"):
didFall = true;
playerAnimator.Play("Player_LeftFall");
print("left");
break;
}
}
However…it doesn’t seem to always work properly. For instance, from these images, you can see that the “right” collider was the one that passed into the trigger yet for some reason it says it was the “top”, but they didn’t even touch…I’m very confused not sure what’s going on. So I guess, it might not be the trigger collider but could be the code itself.
Any insight would be much appreciated! Please let me know if any more info is needed.