- Home /
 
               Question by 
               khachuynguyen · May 23 at 01:51 PM · 
                physicsunity 2dphysics2d  
              
 
              Unity Physics2D.OverlapAreaAll not picking up any colliders
Hi, I have the following relatively simple code.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GameRTSController : MonoBehaviour
 {
     private Vector3 startPosition; 
     void Update() {
 
         if (Input.GetMouseButtonDown(0)) {
             startPosition = Input.mousePosition;
         }
 
         if (Input.GetMouseButtonUp(0)) {
             Debug.Log(startPosition + " " + Input.mousePosition);
             Collider2D[] collider2DArray = Physics2D.OverlapAreaAll(startPosition, Input.mousePosition);
             Debug.Log(collider2DArray);
             foreach (Collider2D collider2D in collider2DArray) {
                 Debug.Log(collider2D);
             }
         }
 
     }
 }
But I'm unable to detect any of the colliders in the scene.

Any advice?
 
                 
                screen-shot-2022-05-21-at-101748-pm.png 
                (452.2 kB) 
               
 
                
                 
                screen-shot-2022-05-21-at-101748-pm.png 
                (452.2 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                