Hello Unity3D.I have a problem with my combo script.Anytime i put my combo script into my character.My character freezes and is not able to do the combo or anything at all.If anyone knows why this problem occurs.Can anyone please tell me why?(I have been stuck on this for 2 weeks now…)
P.S Heres a script i have been trying to get with
var comboCount : int = 0;
var fireRate : float = 3;
var timer : float = 0;
var emptygo:GameObject;
var recordInput : String = "";
var waitClearSeconds : float = 1;
function Update()
{
RecordInput();
waitClearSeconds -= Time.deltatime;
if(waitClearSeconds < 0f) {
GetCombo();
Clear();
}
else
waitClearSeconds -= Time.deltaTime; // This is only reduce when it is grater than 0.
}
function RecordInput() {
if (Input.GetKeyDown("p"))
{
if (!fired)
{
fired = true;
timer = 0.0;
comboCount = 1;
Debug.Log("I served a punch!");
//Do something awesome to deliver a punch!
animation.Play("Rex_Demon__Attack_1");
recordInput += "p";
waitClearSeconds = 1; //reset the wait time to avoid clearing too early
audio.Play(); //Finally play the audio
audio.volume = 50;
emptygo.GetComponent.<Rigidbody>().velocity = emptygo.transform.TransformDirection(Vector3.forward);
emptygo.rigidbody.AddForce(emptygo.transform.forward * 5);
}
else
{
fireRate -= Time.deltaTime;
comboCount++;
if (comboCount == 2)
{
Debug.Log("I did a combo!");
//Do something awesome for the combo!
animation.Play("Rex_Demon__Attack_2");
recordInput += "p";
waitClearSeconds = 1f; //reset the wait time to avoid clearing too early
}
else
{
comboCount++;
if (comboCount == 4)
{
Debug.Log("I did a combo!");
//Do something awesome for the combo!
animation.Play("Rex_s_Combo_Finish_2");
animation["Rex_s_Combo_Finish_2"].speed= 2;
recordInput += "p";
waitClearSeconds = 1f; //reset the wait time to avoid clearing too early
}
else
{
comboCount++;
if (comboCount == 6)
Debug.Log("I did a combo!");
//Do something awesome for the combo!
animation.Play("Rex_Demon__Attack_3");
GetCombo();
}
}
}
}
if (fired)
{
timer += Time.deltaTime;
if (timer > fireRate)
{
comboCount = 0;
fired = false;
}
}
}
function GetCombo() {
if((Input.GetKeyDown("k")&&recordInput == "ppp"))
{
animation.Play("Spinning_Slashes");
waitClearSeconds = 1f; //reset the wait time to avoid clearing too early
}
}
function Clear() {
recordInput = "";
}