x


additive animation wont stop playing

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;
        }
more ▼

asked Mar 15 '11 at 12:11 AM

TinyUtopia gravatar image

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.

Mar 15 '11 at 09:52 AM TinyUtopia

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.

Mar 15 '11 at 01:51 PM TinyUtopia

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.

Mar 15 '11 at 02:54 PM TinyUtopia
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3791
x94
x38

asked: Mar 15 '11 at 12:11 AM

Seen: 900 times

Last Updated: Mar 15 '11 at 12:11 AM