Im trying to create a visual effect where a bunch of cubes play an animation when a growing spherical trigger engulfs them.
Let me explain further...
various scattered cubes are laid out. they all have a script that has collision detection on them that tells them to play an animation once the collision happens.
Then there is a sphere collider that has an animation that scales its radius to a huge value over 2 secs.
In theory, what should happen is once a cube is inside the sphere because it has scaled over it, the script should run - but it's not. The only way I can get a detection to happen is if I put rigid bodies on each but then the sphere just pushes the cubes along.
I've tried using a trigger, but to do so I need to place the script on the sphere object and then it will require a giant list of pre-defined objects to check to see which cubes to affect, which I don't want - I want it to be dynamic.
any ideas on how to do this? the easiest way I can think of is somehow making the rigid body not affect anything, is that even possible?
Thank you so much for helping out! so here is the script that works:
What I needed to do was make it a trigger so that it doesnt push anything around, but still leaving the rigid body there. It works like a charm now! Thank you so much for the help!
Does the code you posted actually compile? (I haven't tried it, but I'd expect the variable name 'Collision' to generate an error. I don't use UnityScript though, so maybe there's something going on there that I'm not aware of.)
Regarding the problem you describe, I'd expect that if you made the sphere collider a trigger and then used OnTriggerEnter() rather than OnCollisionEnter(), it would work. Have you tried that?
answered Jan 08 '11 at 09:11 PM