Question by
Trollwarlol · Jul 10, 2016 at 09:36 PM ·
how
What's wrong with my script for MOBA spell?
using UnityEngine;
using System.Collections;
public class Ability1 : MonoBehaviour {
public GameObject cube;
public Texture2D ab1;
public Texture2D ab1CD;
float ab1Timer = 0;
public float ab1CDTime;
void OnGUI () {
Ab1Timer -= Time.deltaTime;
bool ab1Key = Input.GetKeyDown (KeyCode.Q);
if (ab1timer <= 0) {
GUI.Label (new Rect(10, 10, 50, 50), ab1);
if (ab1Key) {
AbilityOne();
}
} else {
GUI.Label (new Rect(10, 10, 50, 50), ab1CD);
}
}
void AbilityOne () {
instantiate (cube, Vector3.zero, Quaternion.identity);
ab1Timer = ab1CDTime;
}
}
Comment
Not really helpful to post a script, asking what's wrong without giving any further information. If you're using deltaTime, you should do it in Update(). OnGUI can be called multiple times per frame.
Your answer
Follow this Question
Related Questions
There is no way to actually download unity 1 Answer
How to make an animation? 0 Answers
Script conflict 0 Answers
Issue with loading scenes with buttons 1 Answer
Renew License 1 Answer