x


Select a group of gameobjects that are contiguous

Suppose you have several groups of objects that are touching each other, but each group is not touching the other.

How do you select each contiguous group -- if you start by selecting one of the game objects in one of the groups, how do you select the entire contiguous group that this object belongs to (i.e., all the other game objects in this group that touch each other).

more ▼

asked Apr 16 '12 at 04:41 AM

ina gravatar image

ina
3.4k 500 554 615

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

1 answer: sort voted first

Not sure how your "Selection" system works, but you should be able to use OnCollisionStay, I think.

This will allow you to check if that object is "Selected" and if so it will give you a collision list of all the objects that are colliding with it.

more ▼

answered Apr 16 '12 at 04:44 AM

Atrius gravatar image

Atrius
152 1 3

OnCollisionStay looks useful, but I am also trying to figure out the logic of selecting beyond what one object is currently touching (ie what the other ones touching it are touching, for the contiguous "mass")

Apr 16 '12 at 08:11 PM ina

Well, it's sounding like you need to create a recursive function. You could use Physics.OverlapSphere() to check on demand around an object, and then call the same function on all child colliders you find, and add them all to some sort of static/global list of selected objects.

Apr 16 '12 at 11:20 PM Atrius

for OverlapSphere, do you know what bounding volumes vs actual colliders in, when the refer to it in the note: "Currently this only checks against the bounding volumes of the colliders not against the actual colliders"

Apr 17 '12 at 06:31 AM ina

Sorry for late response. My assumption is that bounding box refers to Collider.bounds. Which is a simple rect encompassing the collider but not the actual collider shape. http://unity3d.com/support/documentation/ScriptReference/Bounds.html

Apr 21 '12 at 02:57 AM Atrius
(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
x2172
x1580
x1332

asked: Apr 16 '12 at 04:41 AM

Seen: 598 times

Last Updated: Apr 21 '12 at 02:57 AM