|
Hey everyone anyone know how to keep randomly instantiated objects from spawning on top of other objects like walls or previously spawned objects. here's the random spawn script:
(comments are locked)
|
|
Put an object that detects collisions within the spawn range, upon collision it deactivates that spawn or displaces the spawn to a new location. So basically oncollision with the off limits part delete the object and subtract 1 from spawn?(spawn is the number of objects tht will b instantiated)
Mar 17 '11 at 02:21 AM
G54
Depending on your set up, that would be a solution. Of course there are many implementations to many solutions though.
Mar 18 '11 at 06:58 AM
Lab013
Yup works great. Thank you very much. Now would I be able to do the same to keep objects a certain distance away. Like adding a sphere collider around the object and if another object is inside it deletes and adds back to spawn? is there an easier way?
Mar 18 '11 at 07:13 PM
G54
You could use a sphere collider, or calculate the distance in-between objects. I recommend you also ray cast (Physics.Raycast) to make sure there isn't a wall between one player/enemy and the spawn, because if there is a wall then it doesn't matter if they're close.
Mar 18 '11 at 09:24 PM
Lab013
(comments are locked)
|
