Avoid colliders when instantiating
Hello! First of all I am a complete beginner, so please try to answer me as explained as possible and I'll try my best to understand the solutions. I have a variable randomPosition set as a random range that covers my 3d very simple square room and then Instantiate a prefab gameobject, some magic mushrooms, to that randomPosition. No problem with that. But there are objects like bushes, a bench etc in the room, and I want to avoid the gameobjects to spawn in top of those or inside those. These room decorations have colliders, of course. I've seen people talk about Physics.CheckBox but I'm not sure how I would use it in my script. My simple and newbie mind thought about checking if randomPosition is inside a collider, if it is then do nothing and if it is not, run the instantiate command. Is there any way to check that? Again, I wouldn't be really sure how to use it and if I have to create a variable beforehand and whatnot. I have also read stuff about that but we have to use triggers and I think it would be a hassle to add triggers to all the decorations and stuff. I am sorry if this is unnecessary long or if I didn't explain clearly enough. Again, I will try to consider all possible answers. Thank you!!
Your answer
Follow this Question
Related Questions
Random.Range does not work in the specified range 0 Answers
C# gameobject moving in specific area or collide with wall 0 Answers
Cannot destroy the SphereCollider on Instantiated Objects 1 Answer
Destroy instatiate object on trigger enter / collision,destroy instantiate prefab on trigger enter 0 Answers
IsTouching() not working right after Colliders2D movement/instanciation 0 Answers