Hi ,
ihave this code attached to my character all the animation work perfectly except for the attack with tail i really can’t figure it out
//var animation: Animation;
var maxForwardSpeed : float = 6;
private var jumping : boolean = false;
var character : CharacterController;
var thisTransform : Transform;
function Start() {
character = GetComponent( CharacterController );
thisTransform = transform;
}
function Update () {
var characterVelocity = character.velocity;
var horizontalVelocity : Vector3 = characterVelocity;
horizontalVelocity.y = 0;
var speed = horizontalVelocity.magnitude;
//produit scalaire thisTransform.up et characterVelocity
var upwardsMotion = Vector3.Dot( thisTransform.up, characterVelocity );
//check to see if the character is jumping
if(!character.isGrounded )
{
jumping=true;
}
else
{
jumping=false;
}
if ( jumping )
{
animation[ "jumpfinal"].speed=0.25;
animation.Play("jumpfinal");
}
else if ( speed > 0 )
{
var forwardMotion = Vector3.Dot( thisTransform.forward, horizontalVelocity );
//variable that will be used while lerping
var t = 0.0;
t = Mathf.Clamp( Mathf.Abs( speed / maxForwardSpeed ), 0, maxForwardSpeed );
animation[ "hop" ].speed = Mathf.Lerp( 0.25, 1, t );
//if the character is idle
if (animation.IsPlaying( "idle" ) )
//paly walk without blending
{
animation.Play( "hop" );
}
}
//if none of the condition is met
else
{
//play idle
idlewait () ;
}
// if the player is punching
if(JoyButtons.IsPunshing)
{animation[ "punch" ].speed =2.5;
animation.Play("punch");
animation.PlayQueued("idle");
JoyButtons.IsPunshing=false;
}
//if the player is throwing
if(JoyButtons.IsThrowing)
{animation[ "Throw" ].speed =2.5;
animation.Play("Throw");
animation.PlayQueued("idle");
JoyButtons.IsThrowing=false;}
}
//if the player is attacking with tail
if(JoyButtons.IsTail)
{
animation.Play("Tail");
animation.PlayQueued("idle");
print("play animation tail ");
JoyButtons.IsTail=false;
}
function idlewait ()
{
yield WaitForSeconds (5) ;
animation.CrossFade( "idle" );
}
Ps :IsTail is a boolean variable that’s true when the player touch a gui texture the button work just fine .The message “play animation tail” always appear on the console after i stop the game .
Thanks