Hello. I just need some help figuring out why won’t unity detect that when the left button is pressed the bools that are in the if parameters have to change to “true” from “false”. I leave the code here. I’d be glad if someone helped me on this one.
NOTE: IBA stands for: in between attacks.
NA stands for: Next attack.
using UnityEngine;
using System.Collections;
public class MeeleAttack : MonoBehaviour {
public bool attack1 =false;
public bool attack2 = false;
public bool attack3 = false;
float IBA = 1.0f;
float NA = 0.0f;
bool Combo1 =false;
// Use this for initialization
void Awake (){
}
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (1)){
attack1 =true;
NA = Time.time + IBA;
Debug.Log("Pressed left click.");
}
if(Input.GetMouseButtonDown(1)&& Time.time <= NA){
attack2 =true;
NA = Time.time + IBA;
Combo1 = true;
Debug.Log("Pressed left click.");
}
if(Input.GetMouseButtonDown(1)&& Time.time <= NA&& Combo1 == true){
attack3 = true;
Debug.Log("Pressed left click.");
}
}
}
I added the debug.log marks to check if the button was detected. Thing is that i get 3 debug logs at the same time, which means that the three ifs are acting at the same time, should i go for a switch case method? Thanks for all the help.