سؤال

I have a sphere build from multiple objects. What I want to do is when I touch/click an object, that object should find all adjunctive objects. But because none off them are moving, no collision detection can be used.

I can't find a way to detect these adjunctive objects even when the colliders do collide with each other, as I can see that in the scene. I tried all the possibilities, but none off them are working, because no objects are moving.

Is there a way to check for manual collision detection, or is there some sort of way to let Unity3d do the collision detection automatically?

هل كانت مفيدة؟

المحلول 4

I managed to work around this by checking the distance from the selected object and all other objects that are part of the sphere. If the distance is below a certain value, then it is an adjunctive object.

Although this is certaintly not fool proof, it works without problems so far. I am sorry I was not clear enough. Thanks for all the advice what so ever.

نصائح أخرى

You could keep a list of all those objects, then when your event happens you can send messages to all them to do what you want them to do.

Lets assume you want your sphere to break into little pieces. You send a Force message to the sphere. Then you use Newton's Laws of motion and find out how much velocity each piece gets. Remember velocity is a vector thus it has direction.


This is how I would do it and still keep the right amount of control over what happens in my game/simulation. Remember F = ma.

you could use RaycastHit (http://docs.unity3d.com/Documentation/ScriptReference/RaycastHit.html) for your collision, this also works on non-moving objects but it needs more performance

You can add rigidbody to every objects; when you touch one of them, give a force onto it, then it is going to move and trigger event of the adjacent objects.

for the reason you do not want to move the object you touch, you can cancel movement in the OnCollider or OnTrigger event handler function.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top