- Home /
load specific element of animation via var
Hallo, try to post my question in different way
maybe is better understood and will be answered
I will use this easy code, to activate all the animations of door, lift, and other who have two clip,
for exemple the door animation have OpenDoor and CloseDooor clips
the problem come when i try to load a specific clip from the door in this way is called the first clip only. OpenDoor
var animatedObj1 : GameObject; // Dooor
var animatedObj2 : GameObject; // Button
function Active()
{
animatedObj1.animation.Play();
animatedObj2.animation.Play();
}
I Try
>> var AnimcCip : AnimationCilp;
to load specific clip OpenDoor or CloseDoor
and various way to do but not work at all or
even doesn't display any error loading the script
receive that's error when play
NullReferenceException: Object reference not set to an instance of an object
CameraRayReciver1.js(13,74): BCE0048: Type 'System.Type' does not support slicing.
if write directly the name of clip its work, but I need the var to reuse the script
Thanks to all can help my
ok using var anim: AnimationClip;
I'm able to load OpenDoor o Close Door animation
but now receive ever thats error
NullReferenceException: Object reference not set to an instance of an object
CameraRayReciver1.js(13,74): BCE0048: Type 'System.Type' does not support slicing.
please someone give me help, I'm very stuck
thanks
Answer by whydoidoit · Jul 13, 2012 at 05:32 PM
You can load an animation using Animation.AddClip(yourClip,"nameOfClip") or Animation.AddClip(yourClip, yourClip.name)
Given a clip you can do
animation.Play(clip.name);
Answer by Ingen · Jul 16, 2012 at 05:16 PM
thanks you
I've some trouble to use " Animation.AddClip "
but this answer put me on the way to do this
var animatedObj1 : GameObject; // Dooor at plane 0
var animatedObj2 : GameObject; // Button
var animatedObj3 : GameObject; // Lift
var animatedObj4 : GameObject; //Dooor at plane1
var anim1clip: AnimationClip ; // Dooor at plane 0 close
var anim3clip: AnimationClip ;// Lift go up
var anim4clip: AnimationClip ;//Dooor at plane1 Open
function Active()
{
animatedObj2. animation.Play();
animatedObj1.animation.Play(anim1clip.name);
yield WaitForSeconds (2); // time door is close
animatedObj3.animation.Play(anim3clip.name);
yield WaitForSeconds (10); // time lift move
animatedObj4.animation.Play(anim4clip.name);
}
I'm not sure if is a good way but work!
Your answer
Follow this Question
Related Questions
Putting animations variables and run? 1 Answer
Animation.Play(useVar) 0 Answers
Enable and disable one button from a Static Var? 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers