I've created an animation player that uses a secondary animation which resides on top level layer and plays using AnimationBlendMode.Additive. It's blending fine, but the problem that I'm having is that it won't stop playing. Regardless of if I put the wrapMode as Once or Clampforever, it still forces the lower level animation to continue to loop.
private var leanLeft : AnimationState;
function Start(){
leanLeft = animTarget.animation["A1LFoot"];
leanLeft.layer = 10;
leanLeft.blendMode = AnimationBlendMode.Additive;
leanLeft.wrapMode = WrapMode.ClampForever;
leanLeft.weight = 1.0;
leanLeft.enabled = false; // This makes sure the additive animation is turned off normally
}
function Update()
{
var hit : RaycastHit;
//ray shooting out of the camera from where the mouse is
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, hit)){
//print out the name if the raycast hits something
Debug.Log(hit.collider.name);
if (hit.collider.name == "HitObject"){
PlayAdditive();
}
}
function PlayAdditive(){
Debug.Log("Playing Animation Additive");
leanLeft.weight = 1.0;
leanLeft.enabled = true;
}
asked
Mar 15 '11 at 12:11 AM
TinyUtopia
270
●
22
●
26
●
38
I think I discovered the root of the problem. When I load the animation file for the additive process, I do so be referencing it from the animation object. i.e. leanLeft = animTarget.animation["A1LFoot"]; This causes all of the animations in that object to loop even when they are not set to do so.
I tried making a new script from the exact example @ http://unity3d.com/support/documentation/Manual/Character-Animation.html
This resulted in the same outcome. Even though the additive animation is working correctly, adding the script directly to character GameObject results in the (lower level) animations being continuously looped regardless of their individual settings.
I discovered the problem. The WrapMode of the Character GameObject is determined by the base animation WrapMode, even if it is on a lower layer than the additive animation. This makes sense.