Hi guys so I am making a 3rd person game and I got the character to finally swing his sword. The only problem I had was that if you keep holding down the forward button, he kept moving while the animation was happening. I used this script to stop his movement only when he swung by changing the walkSpeed, trotSpeed and runSpeed variables in the ThirdPersonController script all to 0, then reassigning them after .5 seconds to their normal values. Every time I try to run it, the console says I need an instance of ThirdPersonController in order to call the non-static variables. Could someone please tell me what is wrong with my code?
Thanks in advance.
#pragma strict
var clip : AnimationClip;
function Start ()
{
animation["spartanattack"].layer = 1;
animation.Stop();
}
function Update()
{
if (Input.GetMouseButtonDown(0))
{
animation.Play("spartanattack");
ThirdPersonController.walkSpeed = 0;
ThirdPersonController.trotSpeed = 0;
ThirdPersonController.runSpeed = 0;
Invoke("AttackDelay", .5);
}
}
function AttackDelay ()
{
ThirdPersonController.walkSpeed = 7;
ThirdPersonController.trotSpeed = 7;
ThirdPersonController.runSpeed = 25;
}
maybe it needs a code that disables the 3rd person controller on attack
its the 3rd person controller that does not allows you to play the animation i tested it