I’m trying to basically get this script to check (every frame) that the key is held down to run the if-then statements.currently it only checks on the frame that the button is pushed. I am wanting it to check every 3 seconds to run the if-then statements if someone could help me get started with that as well.
using UnityEngine;
using System.Collections;
public class RandomBattles : MonoBehaviour {
private int RandNum;
public bool InBattle;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RandNum = Random.Range(1, 1000);
if (Input.GetKeyDown(KeyCode.W)||Input.GetKeyDown(KeyCode.S)){
if(RandNum > 1){
if(RandNum < 1000){
inBattle ();
}
}
}
}
void inBattle () {
Debug.Log ("battle");
}
}