Im trying to add Mixing Transform to my game and I found this example
http://www.indiegamesstudio.com/wiki/tiki-index.php?page=Unity+Animation
and I changed the script a little to meet my needs
var spine : Transform;
private var Guns : AnimationState;
private var runanim : AnimationState;
private var idleanim : AnimationState;
function start ()
{
Guns = animation["DrawGuns"];
Guns.layer = 1;
Guns.wrapMode = WrapMode.ClampForever;
Guns.AddMixingTransform (spine);
runanim = animation["run"];
runanim.layer = 2;
runanim.blendMode = AnimationBlendMode.Blend;
runanim.enabled = false;
runanim.weight = 1.0f;
runanim.AddMixingTransform(transform);
idleanim = animation["idle"];
idleanim.layer = 2;
idleanim.blendMode = AnimationBlendMode.Blend;
idleanim.enabled = false;
idleanim.weight = 1.0f;
idleanim.AddMixingTransform(transform);
}
function Update ()
{
if (Input.GetKey("w"))
runanim.enabled = true;
idleanim.enabled = false;
if (Input.GetKeyDown ("k"))
Guns.enabled = true;
}
Nothing happens
no animations play at all.
I tried doing this
function start ()
{
shootanim = animation["DrawGuns"];
shootanim.layer = 2;
shootanim.blendMode = AnimationBlendMode.Blend;
shootanim.wrapMode = WrapMode.ClampForever;
shootanim.enabled = false;
shootanim.weight = 1.0;
shootanim.AddMixingTransform(spine);
animation ["run"].layer = 1;
animation ["idle"].layer = 1;
animation ["run"].weight = 0.1;
}
function Update ()
{
if (Input.GetKey("w"))
animation.CrossFade ("run");
else
animation.CrossFade ("idle");
if (Input.GetKeyDown ("k"))
shootanim.enabled = true;
}
![]()