Hello everyone,
I have a player character whose movement works just fine along both the horizontal and vertical axis. Moreover, the character’s walk animation works as expected, with all crossfading working as it normally would given that all the model’s animation wrap mode is loop. However, the character’s punch and kick animations are not playing at all when the relevant buttons are pressed. Here is my PlayerAttack.js script:
var punchSpeed = 1;
var punchHitTime = 0.2;
var punchTime = 0.4;
var punchPosition = new Vector3 (0, 0, 0.8);
var punchRadius = 1.3;
var punchHitPoints = 1;
var kickSpeed = 1;
var kickHitTime = 0.2;
var kickTime = 0.4;
var kickPosition = new Vector3 (0, 0, 0.8);
var kickRadius = 1.3;
var kickHitPoints = 1;
var bashSound : AudioClip;
private var busy = false;
function Start ()
{
animation["punch_r"].speed = punchSpeed;
animation["kick_r"].speed = kickSpeed;
}
function Update ()
{
var controller : ThirdPersonController = GetComponent(ThirdPersonController);
if(!busy && Input.GetButtonDown("Punch"))
{
SendMessage ("DidPunch");
busy = true;
}
if(!busy && Input.GetButtonDown("Kick"))
{
SendMessage ("DidKick");
busy = true;
}
}
function DidPunch ()
{
Debug.Log("Punching...");
animation.CrossFadeQueued("punch_r", 0.1, QueueMode.PlayNow);
yield WaitForSeconds(punchHitTime);
var pos = transform.TransformPoint(punchPosition);
yield WaitForSeconds(punchTime - punchHitTime);
busy = false;
}
function DidKick ()
{
Debug.Log("Kicking...");
animation.CrossFadeQueued("kick_r", 0.1, QueueMode.PlayNow);
yield WaitForSeconds(kickHitTime);
var pos = transform.TransformPoint(kickPosition);
yield WaitForSeconds(kickTime - kickHitTime);
busy = false;
}
The Debug.Log() messages for each attack show up just fine in the console, so I’m 99% certain that it’s not a code issue. However, since I checked All Animations in Blender when I exported my .fbx file from Blender 2.5.7 to Unity 3.4.2, I can’t figure out how it can be an issue with my Blender file. Any and all help will be appreciated.
MachCUBED