- Home /
Combo Script Problem
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
#pragma strict
var recordInput : String = "";
var waitClearSeconds : float = 1; //wait 1 second adter the last input before clear, you will have to adjust this setting later
function Update() {
RecordInput();
waitClearSeconds -= Time.deltaTime;
if(waitClearSeconds < 0f) {
GetCombo();
Clear();
}
}
function RecordInput() {
Input.GetKeyDown("k");
{
animation.Play("Rex_Sword_Kick");
recordInput += "k";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
Input.GetKeyDown("k");
{
animation.Play("Rex_Sword_Kick_2");
recordInput += "kk";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
Input.GetKeyDown("k");
{
animation.Play("Rex_Seal_Combo");
recordInput += "kkk";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
}
function GetCombo() {
if(recordInput == "kkk")
Input.GetKeyDown("p");
{
animation.Play("Spinning_Slashes");
recordInput += "kkkp";
waitClearSeconds = 0.2f;
}
}
function Clear() {
recordInput = "";
}
You appear to be missing a bunch of if statements around your Inputs.
I believe no-one has looked at it due to the title.
this is what you should do to check if a key is pressed
if(Input.Get$$anonymous$$eyDown("key"))
{
// your code here
}
@ meat5000 oh yea sorry....I forgot to change it ;-;....
@Inan Evin i did it but the player still doesnt move...
#pragma strict
var recordInput : String = "";
var waitClearSeconds : float = 1; //wait 1 second adter the last input before clear, you will have to adjust this setting later
function Update() {
RecordInput();
waitClearSeconds -= Time.deltaTime;
if(waitClearSeconds < 0f) {
GetCombo();
Clear();
}
}
function RecordInput() {
if(Input.Get$$anonymous$$eyDown("k"));
{
animation.Play("Rex_Sword_$$anonymous$$ick");
recordInput += "k";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
if(Input.Get$$anonymous$$eyDown("k"));
{
animation.Play("Rex_Sword_$$anonymous$$ick_2");
recordInput += "kk";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
if(Input.Get$$anonymous$$eyDown("k"));
{
animation.Play("Rex_Seal_Combo");
recordInput += "kkk";
waitClearSeconds = 0.2f; //reset the wait time to avoid clearing too early
}
}
Answer by Derek-Wong · Feb 03, 2015 at 02:13 AM
your 3 if statements are checking the same conditions...so they will all triggered when you press k
It Still didnt work DX.....Why is this so hard?!
#pragma strict
var recordInput : String = "";
var waitClearSeconds : float = 1; //wait 1 second after the last input before clear, you will have to adjust this setting later
function Update() {
RecordInput();
waitClearSeconds -= Time.deltaTime;
if(waitClearSeconds < 0f) {
GetCombo();
Clear();
}
}
function RecordInput() {
if(Input.Get$$anonymous$$eyDown("k"));
{
animation.Play("Rex_Sword_$$anonymous$$ick");
recordInput += "k";
waitClearSeconds = 0.1f; //reset the wait time to avoid clearing too early
}
{
animation.Play("Rex_Sword_$$anonymous$$ick_2");
recordInput += "kk";
waitClearSeconds = 0.2; //reset the wait time to avoid clearing too early
}
{
animation.Play("Rex_Seal_Combo");
recordInput += "kkk";
waitClearSeconds = 0.3f; //reset the wait time to avoid clearing too early
}
}
function GetCombo() {
if(recordInput == "kkk")
if(Input.Get$$anonymous$$eyDown("p"));
{
animation.Play("Spinning_Slashes");
recordInput += "kkkp";
waitClearSeconds = 0.4f;
}
}
function Clear() {
recordInput = "";
}
Your answer
Follow this Question
Related Questions
Combo Script Problem 1 Answer
Cable-building simulations. 0 Answers
Raycast script help? 1 Answer
Make tranform follow raycast 1 Answer
get all text between two chars (js) 1 Answer