Physics.checkbox

I’m trying to get a box to switch between two layers, but before it can do that, it needs to check that there’s nothing occupying a certain collision box trigger.
Initially, I used “on trigger enter” and “on trigger exit” and just counted how many objects entered and exited its trigger.
However, this will not work, because objects that are destroyed while in the box are not taken into account, nor are objects that start the scene already inside the trigger.

So I’m trying to use “physics.checkbox” instead, but I can’t seem to find any good documentation on it. The official documentation doesn’t provide any examples, and any forum posts about it are full of people recommending the “onTriggerEnter” method instead.
Because of this, I am having trouble figuring out how to get this to work.

public GameObject returnParent;
private Vector3 selfCol;

void Awake(){
selfCol = GetComponent<BoxCollider> ().size;
}

void FixedUpdate(){
empty = Physics.CheckBox (selfCol/2,selfCol);
}```

use Physics.Checkphere(vector3() , sphere radius); as a condition

ex if(Physics.CheckSphere(new Vector3(x,y,z), 1))
empty = true;

First time I see checkbox, I use boxcast.

what are you having trouble figuring out about it?

1 Like