Sometimes we need to detect if a Gameobject collided with a especific side of another GameObject, or even a side of the Screen.
We can do that cheking the "Normal" of the collision´s angle.
if (collision.collider.name == "Wall") { // collided with screen top
Vector2 normal = collision.contacts[0].normal;
if (normal == Vector2.down)
{
this.enabled = false;
}
}
Nenhum comentário:
Postar um comentário