Answers for "spawn enemy if space is not occupied unity"

C#
1

spawn enemy if space is not occupied unity

var spawnPoint:Vector3 = square.position;
 var hitColliders = Physics.OverlapSphere(spawnPoint, 1); //1 is purely chosen arbitrarly
 if(hitColliders.Length > 0)
 {
 	//You have something here
 }
 
 //2D
 var hitColliders = Physics2D.OverlapCircleAll(spawnPoint, 0.25f);//0.25 is just a random radius the worked for me
 if(hitColliders.Length > 0)
 {
 	//You have something here
 }
Posted by: Guest on January-26-2021

Code answers related to "spawn enemy if space is not occupied unity"

C# Answers by Framework

Browse Popular Code Answers by Language