- Home /
Question by
Weirdo-Studios · Jun 20, 2013 at 05:53 PM ·
errormissingmethodcrossfade
Animation CrossFade Help Missing Method
Ok, so i have my animations and there on my model and the script is on there but when i play i get an error : MissingMethodException: UnityEngine.Animation.CossFade
var PlayerState : float;
var PlayerAnimSec : GameObject;
function Update ()
{
PlayerStateController ();
PlayerAnims ();
}
function PlayerStateController ()
{
if ((Input.GetAxis("Vertical") !=0 || Input.GetAxis("Horizontal") !=0))
{
if (Input.GetButton("Sprint"))
{
PlayerState = 2;
}
else
{
Playerstate = 1;
}
}
else
{
PlayerState = 0;
}
}
function PlayerAnims()
{
if (PlayerState == 0)
{
PlayerAnimSec.animation.CossFade("Idle Animation", 0.4);
}
else if (PlayerState == 1)
{
PlayerAnimSec.animation.CossFade("Walk Animation", 0.4);
}
else if (PlayerState == 2)
{
PlayerAnimSec.animation.CossFade("Sprint Animation", 0.4);
}
}
Comment
Answer by Weirdo-Studios · Jun 26, 2013 at 03:25 PM
Ok so I figured this out myself... if anyojne ahs the same issue or wants to know how to do idle sprinting and walking animations here you go.
var sprinting : boolean = false; var walking : boolean = false;
//coded by Weirdo Studios
function Update () {
if (Input.GetAxis("Horizontal")== 0) { walking = false; }
if (Input.GetAxis("Horizontal")== 0)
{
walking = false;
}
if (Input.GetButtonUp("Sprint"))
{
sprinting = false;
}
if (Input.GetAxis("Vertical"))
{
walking = true;
}
if (Input.GetAxis("Horizontal"))
{
walking = true;
}
if (Input.GetButtonDown("Sprint"))
{
sprinting = true;
}
if (sprinting == true)
{
walking = false;
animation.CrossFade("Sprint Animation", 0.2);
}
else if(walking == true)
{
animation.CrossFade("Walking Animation",0.2);
}
else
{
animation.CrossFade("Idle Animation",0.1);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613104535im_/https://answers.unity.com/themes/thub/images/avi.jpg)