Untitled

 avatar
unknown
plain_text
a year ago
813 B
4
Indexable
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.)
        }
    }
}
Editor is loading...
Leave a Comment