I made two animations both Wrap.Mode = Loop (Idle and walking) and I made this script. The problem is that when the player is stopped l ‘animation “Idle” does not start and the player is stuck on’ animation “Walking”.
Help me.
The script.
enum CharacterState
{
Idle,
Walking,
}
public var idleAnimation : AnimationClip;
public var walkAnimation : AnimationClip;
private var _characterState : CharacterState;
function Update()
{ var v = Input.GetAxis("Vertical");
var h = -Input.GetAxis("Horizontal");
if(v || h)
{
_characterState = CharacterState.Walking;
}
else if(v < 0.2 h < 0.2)
{
_characterState = CharacterState.Idle;
}
CheckMovementAnimation();
}
function CheckMovementAnimation()
{
switch(_characterState)
{
case CharacterState.Idle :
animation.Play("Idle");
print("Idle");
break;
case CharacterState.Walking :
animation.Play("Walking");
print("Walking");
break;
}
}
@achingupta87 It doesn’t work. @SteveJ Yes, the case is being exucuted, because it print in console Idle or Walking. I think the problem are the animations.
Yes, you can’t not check model setting in inspector from prefab . but you can check setting of model without prefab means when we import any model in project window then you can check it easily. check Rig>Animation Type>Legacy.
Sorry kryber Now I can not help you more because I don’t no how we play the animation in game object like cubes. I generally use .fbx file which contains already animation I just needs to set some setting in inspector attach a simple script.