Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
813 B
1
Indexable
Never
using UnityEngine;

public class ColliderOverlapTest : MonoBehaviour
{
    private void Start()
    {
        // Get the position of the GameObject this script is attached to
        Vector2 position = transform.position;

        // Get all colliders overlapping with the position
        Collider2D[] colliders = Physics2D.OverlapPointAll(position);

        if (colliders.Length > 0)
        {
            Debug.Log("Colliders found at position " + position + ":");
        }
        
        // Iterate through each collider detected at the position
        foreach (Collider2D collider in colliders)
        {
            Debug.Log("- Collider name: " + collider.name);
            // Add more detailed information if needed (e.g., collider type, properties, etc.)
        }
    }
}
Leave a Comment