- Home /
Question by
FusionSausage · Oct 07, 2013 at 06:38 PM ·
c#instantiateprefabmodel
Only instantiate if clear space beside prefab
Hi, I have a Windmill model which I instantiate in my game. Now, I have mountains and stuff on my terrain, so I only want it to instantiate if there is no colliding things around it (terrain, other prefabs). How do I do that?
Thanks!
Comment
Best Answer
Answer by meat5000 · Oct 07, 2013 at 06:39 PM
http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html
This will detect stuff with colliders in a given radius.
Cool :) $$anonymous$$ark the answer if it works for you
Just a quick question, it looks promising although how does it deter$$anonymous$$e the radius and center? Is it some kind of values I have to add in or is it something that's done automatically?
Physics.OverlapSphere(center, radius); Vector3 and float
Put the values in.