Collision Extensions

Has Tag

This calls the HasTag extension method on the Collision object to determine if the object it collided with has the tag "Enemy". If true, it logs a message indicating the collision.

void OnCollisionEnter(Collision collision)
{
    if (collision.HasTag("Enemy"))
    {
        Debug.Log("Collided with an enemy!");
    }
}

Has Layer

This calls the HasLayer extension method to check if the object collided with is in the "Player" layer. If true, it logs a message indicating the collision.

void OnCollisionEnter(Collision collision)
{
    if (collision.HasLayer("Player"))
    {
        Debug.Log("Collided with the player!");
    }
}

Get All Colliders

This calls the GetAllColliders extension method on the Collision object, retrieving a list of all colliding objects. It then logs the names of those objects.

Get Colliders With Tag

This calls the GetCollidersWithTag extension method on the Collision object, retrieving a list of all colliding objects with the tag "Enemy". It then logs the names of those enemies.

Get Colliders With Layer

This calls the GetCollidersWithTag extension method on the Collision object, retrieving a list of all colliding objects with the tag "Enemy". It then logs the names of those enemies.

Get Contact Points

This calls the GetContactPoints extension method to retrieve the contact points of the collision, logging each point's coordinates.

Get Contact Points

This calls the GetContactPoints extension method to retrieve the contact points of the collision, logging each point's coordinates.

Last updated