- Home /
 
Making an animation on Input run at a speed declared by a variable in another script?
I'm creating a basic RPG, and I need a sword's swinging animation's speed to be affected by a variable I have declared in the player script. I currently have the animation playing at it's set speed on input, so it swings when I press the key that is declared in the 'Swing' input setup, and the variable set to 'float' in the Player script. I have looked at the "animation[clipName].speed = 1;" and I'm not sure how to implement it into what I need. ~~ I want to be able to edit the variable's value in the editor, which I'm not sure is possible with a static var, although this isn't integral, as I will find a better way of doing it. It's more of a debug thing.
This is what I have: The Sword's sript:
 var speed : float;
 private var statsInstance : Playerstats;
 
 function Start ()
 {
     statsInstance = GetComponent(Playerstats);
 }
 
 function Update () 
 {
 
     if(Input.GetButtonDown("Attack"))
         {
         animation["SwordSwingTem"].speed = statsInstance.Agility;
         }
 }
 
 
               The Player's Script:
 #pragma strict
 var Attack : float;
 var Defence : float;
 var Agility : float;
 var Strength : float;
 
 function Start ()
 {
 Screen.showCursor = false;
 }
 
 function Update () 
 {
 
 }
 
               Thanks, the Pangaea Team's 3D Modeller :]
Your answer