x


Detecting collision from Instantiated objects

hey, i've written a quick script that spawns 500 cubes randomly in the volume of a sphere, however i've been unable to find a system to stop the Instantiated objects from intersecting when they spawn.

i know this SHOULD be possible, but with Unity's unhelpful obuste collision detection system i've found it very difficult to work out.

the cubes that i am spawning will be used as collision objects in the game, so they have colliders attached, but i've found no way to reliably destroy any cube that spawns inside another.

i've been trying to figure this out for two days now, so any help is welcome.

thanks in advance

more ▼

asked Sep 08 '11 at 09:15 PM

DrVonTrap gravatar image

DrVonTrap
1 3 3 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can iterate over each previously spawned object and check bounds: http://unity3d.com/support/documentation/ScriptReference/Bounds.Intersects.html

more ▼

answered Sep 08 '11 at 09:41 PM

DaveA gravatar image

DaveA
26.8k 153 171 257

Thanks, i knew there must be a function like this, i just couldn't find it.

Sep 09 '11 at 03:19 PM DrVonTrap
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2584
x1726
x453
x26

asked: Sep 08 '11 at 09:15 PM

Seen: 1270 times

Last Updated: Sep 09 '11 at 08:49 PM