- Home /
Question by
houdamansour2018 · Apr 19, 2020 at 12:26 AM ·
unity4.3
how to make the player can use an ability just after a specific time
how can i make my player per example can use a spell just after after a specific time i mean that the player will use a spell for a specific time and then it will be disabled and he can use it after a specific time
Comment
Answer by parachutingpotatochips · Apr 19, 2020 at 02:17 AM
In whatever script you have your ability using in add this:
float countDown;
float time = //however many seconds;
bool canUseAbility;
//if this bool is true, you can use the ability
void Start{
canUseAbility = false;
countDown = time;
}
void Update{
if(countDown <= 0){
canUseAbility = true;
}
else{
countDown -= Time.deltaTime;
//count down
}
}
//as an example, to use the ability you will press space
if(Input.GetKeyDown(KeyCode.Space))
{
if(canUseAbility){
//Use ability
canUseAbility = false;
countDown = time;
}
Your answer
Follow this Question
Related Questions
2d sprite alwayes overlay 3d game object? 1 Answer
Moving object show jerks in middle of Image. 0 Answers
Water Fire Effect On 2d Game 1 Answer
Value between two states 2 Answers
On start display trail renderer 0 Answers