- Home /
Referring to an animation NUMBER via script?
Hi again guys. Just a real simple question, couldn't find the answer in the manual. Also tried fiddling with the autocompletion help in Visual Studio, but couldn't come up with anything there.
For a streamlined level-building process, I have it so that a door-opening button can be linked via a public variable to any game object I need to be a door or bridge or whatever else I need to become "activated" and play an opening animation. I primarily do this because I need the freedom to make unique doors and bridges and such whenever I need with their own unique animations, and all I have to do is hook my generic button object to it and it works (a simple but neat little workflow idea anyone is free to use, of course :)).
Having one little problem. What line(s) of code would I use to play, say, animation element 1 for an object? That way no matter what that animation is named, I can always reliably activate it without needing the name if it's in the correct element slot.
I'd recommend using the names, rather than the indices. Although not perfect, names will be easier for workflow than indices. Just add a public variable to that door-opening button component you mentioned for 'open animation name'. Then you have total flexibility, and don't need to worry about indices.
I suppose. Only reason I wanted to know was that I can't have two animations with the exact same name. So for Door1 and Door2, I can't have two different animations both named "Open" thus telling my script to always just play the "Open" animation of whatever object was attached, I'd have to have them as "Door1Open" and "Door2Open" etc., although... I guess I could just make the animation that is supposed to play be a public variable on the button, and plug in the animation as well when I go to plug in the door being opened. Well, I'll mill it over for a while!