• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by crocodil · Apr 25, 2017 at 02:35 PM · invokerepeatingtimer countdowndecrease

invoke method attack.decreaseTimeRemaining couldn't be called

So the scene picks a random image of four, at which point I want a count down to start that is waiting for user input, if the countdown hits 0 the user dies if the correct input is pressed then they move to the next scene - no other errors in compiler just invoke can't be called. This is one example of an image chosen. Hope i didn't copy this poorly or make a stupid letter error. please help

using UnityEngine; using UnityEngine.UI; using System.Collections;

public class Attack : MonoBehaviour {

 public float timeRemaining = 2.0f;
 float num;

 void state_AttackUp () { 
     InvokeRepeating ("decreaseTimeRemaining", 1.0f, 1.0f);
     if (Input.GetKeyDown (KeyCode.UpArrow)) {
         CancelInvoke ("decreaseTimeRemaining");
         Application.LoadLevel("Level6");
     } else if (timeRemaining == 0) {
         Application.LoadLevel("Level7");
     }
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image crocodil · Apr 24, 2017 at 03:56 AM 0
Share

I'm trying ways to just set an if statement with time at 2 secs or whatever, but that's not working either.

void Update () { if (Time.time == 2.0) { Application.LoadLevel (7);; } } }

Whatever is easiest.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by crocodil · Apr 27, 2017 at 08:56 AM

I finally found this after six hours of trying different searches. Yay! I hope this helps someone else too.

using UnityEngine; using System.Collections;

public class CountDown : MonoBehaviour {

 public float time;

 void Start() {
     time = 2;
 }
 
 void Update () {
     if(time > 0){
         time-=Time.deltaTime;
     }else{
         Application.LoadLevel(7);
     }
 }

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Increase/Decrease Value With Time - Problem 4 Answers

how to decrease repeating time in invokerepeating? 2 Answers

Calculating BPM (beats per minute) using InvokeRepeating() - Issue 2 Answers

Two InvokeRepeating separate functions turning to work a t the same time 0 Answers

Walker Boys tutorial error 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges