I have the script below that works but it seems too big and unnecessary for the task. I have two rotating "sliding doors" that play with animation from .max file. I don't want to combine the doors to one because they use different materials that are repeated all over the project. I put two overlapping triggers to open them when you approach with the default first person controller.
The triggers are children of the parent animated object because I though that searching by tag or name will be slower. They play the animation with "gameObject.transform.parent...." is that a correct approach ? If I use one trigger I'll have to find the objects by tag and when you have many instances of these tags it seems that things are becoming a bit random on what door is opening. When I do the artwork (yes I am one of those ) I put an empty box called triggerXXX in my model and if I have multiple animations in one file I put multiple triggers as children. I do that because it is faster than snapping in unity and because I don't want to brake the connection with the original models which fills me with metaphysical fear !!! ... of assigning all the layers,the tags, the triggers and the materials again in a later stage. So as a strategy what is the most elegant way of assigning triggers that can work on multiple different objects?
//I duplicated my initial variables to triggerS and triggerT to avoid conflict//
Dump!! me, sorry, I just had to store the animation on the root object, and have only one trigger that plays all the door animations. I separated the model with the different animation (Lift in my case) to another model so that the root gameObject doesn't play the lift animation too. the code looks much better now.
answered Apr 05 '10 at 04:39 PM