Answers for "unity check if position is inside collider"

C#
2

unity check if position is inside collider

//For 3D :
public Collider[] colliders;
public Vector3 yourPosition;
     
     private void CheckPositionInsideCollider()
     {
       colliders = Physics.OverlapSphere(yourPosition, 0.0f);
       return colliders; //returns all the colliders that contain your position
     }

//For 2D :
public Collider2D[] colliders;
public Vector2 yourPosition;
     
     private void CheckPositionInsideCollider()
     {
       colliders = Physics2D.OverlapCircleAll(yourPosition, 0.0f);
       return colliders;
     }
Posted by: Guest on April-18-2021

Code answers related to "unity check if position is inside collider"

C# Answers by Framework

Browse Popular Code Answers by Language