Hi, Im getting started with this Humanoid animation system and I want to play an animation
I found Animator.Play in the documentation but all it says is:
Play(stateName: string, layer: int = -1, normalizedTime: float = float.NegativeInfinity)
which is pretty vague to me so does anyone have any example code using this?
I tried typing that line but my animation isn’t playing,
In my animator u can see the layer is just called “Layer” so I typed,
anim = GetComponent(“Animator”);// typed at function start
anim.Play(“Layer.NameOfAnimation”);
as you can see in the Animator none of the animations there have any links or transtions between them, with this in mind can u guess why the animation isn’t playing?
You don’t need transitions for that. Can you clean that a bit? I can’t see any animation names or stuff like that
Just use a second layer if you don’t want to change your animations.
You only need transitions if you want it to jump back to idle when finished, but not for testing now.
I looked into the animator window while playing and found that the animation is playing but the idle animation is still playing over it.
I could see this from the bar progressing with the animation but the character appeared to still be in idle
they where default before, setting the weight or the second layer to 1 allows me to play the animation. what does override or additive do?
anyway the next step for me is to detect the position of the animation, before I used if(animation.[“name of animation”].normalizedTime >= value), how do I do this using animator?
I need to raise a flag when certain animations reach a point or when it ends, but i need it in code. So how do I use “AnimatorStateInfo.normalizedTime”?
I saw this line
AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
Debug.Log(info.normalizedTime);
how do i write this in javascript?
I don’t know unityscript, sorry.
I would think something like:
var animator:Animator=gameObject.GetComponent(Animator);
var info:AnimatorStateInfo=animator.GetCurrentAnimatorStateInfo(0);
Debug.Log(info.normalizedTime);
not on my computer with unity atm can anyone confirm this
EDIT: this works sorta, but the normalizedTime stacks up with every animation in the layer, I need this value to be reset to zero when an animation ends or starts. can does someone know how. info.normalizedTime is read only so I can’t do something like info.normalizedTime = 0.