Check for Collision before Gameobject Spawn

Hello,

i spawn alot of Gameobjects with this Method:

GameObject _g = Instantiate(collectable.GetGameObject());

Before i spawn the Object i want to Check if this area is free for the full size of this object.

If the object would collide i dosnt want to spawn this.

How can i archive this?

Use some kind of physics query to determine if its hitting anything.
E.g.

actaully i try it with this method

Collider[ ] intersecting = Physics.OverlapBox(transform.position, collectable.GetGameObject().GetComponent().bounds.size);

But that dosnt give me the result what i want.

Can you tell us why that does not work for you? It seems to fit all your requirements, except that we do not know how large the bounds are when you get the game object from collectable.

I think it is because i scale and rotate objects. This Physics.OverlapBox function check only the collision of the Rigidbody. The problem there is cant scale the rigidbody. Even i cant see where the rigidbody is, to figure out the overlap.

Couldn’t you simple create a stand-in box that you know will always work (perhaps it’s bigger than the worst-case Scenario if your prefab) and use that for the check, and then only spawn if there is enough space?

Use the Physics.CheckSphere with layermask if returning false spawn your object