Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
This question was closed Jan 08, 2016 at 03:12 AM by usalalas for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by usalalas · Nov 21, 2015 at 03:33 AM · functions

Functions is not been called

Good Evening,

I´ve got a scrip, and there is a function on it that is not been accessed. Can you help please.

The cod is as follow, public class Manager : MonoBehaviour {

 public float redTimer = 0f;  //Tempo decorrido que o vermelho foi setado
 public float maxRedTimer = 0f; // Maximo tempo para retirar o vermelho
 public float minRedTimer = 0f; // Minimo tempo para retirar o vermelho
 public float actualRedTimer = 0; // tempo atual para retirar o vermelho
 public static bool changeRed = false; // Se esta na hora de mudar para o vermelho
 public static int idRedFrame = 0; // Qual o quadro para colocar o vermelho
 private bool[] usedFrame = new bool[15];     //Array usado para saber quais quadros ja foram usados
                             // O index do Array indica o neumero do quadro.
 //public int loopCount = 0;    // Usado no metodo que zera o Array de quadros usados
 private bool usedFrameCompleted = false; // indica que todo o Array dos quadros usados foi zerada
 private int frameCount = 0; // Quantas frames foram utilizadas
 
 // Use this for initialization
 void Start () {
     actualRedTimer = 3f;
     ResetIdFrame(); // Zerando o Array dos quadros usados pela primeira vez

 }
 
 // Update is called once per frame
 void Update () {
     redTimer += Time.deltaTime; 
     if (redTimer >= actualRedTimer) 
     {
         changeRed = true;
         idRedFrame = FindFrame ();
         redTimer = 0f;
     }
     
     
     
     
     
     
 }
 
 int FindFrame()
 {
     int idFrame;
     idFrame = 0;
     bool gotFrame = false;
     idFrame = Random.Range(0,15);
     while (!gotFrame) {
         if (frameCount < 15) {// Se o Array de quadros nao estiver completo

             if(usedFrame[idFrame])
             {if (idFrame == 14 && usedFrame[idFrame])
                 {
                     idFrame = 0;
                 }else
                 {
                     idFrame++;
                 }

             }else
             {
                 usedFrame[idFrame] = true;
                 gotFrame = true;
                 frameCount++;
             }
         } else {
             ResetIdFrame();
         }
     }
     return idFrame;
 }


     public void ResetIdFrame()  //Metodo para Zerar o Array usedFrame
 {
     int loopCount = 0;
     while (!usedFrameCompleted)
     {
         usedFrame[loopCount] = false;
         loopCount++;
         if (loopCount == 15)
         {
             usedFrameCompleted = true;
             loopCount = 0;
             frameCount = 0; // Indica que nenhuma frame foi utilizada
         }
         
     }
 }
 

}

The function ResetIdFrame is never accessed, and I end up in a endless loop.

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by AngryTilde · Nov 21, 2015 at 10:35 AM

Hey there!

ResetIDFrame is called, it's just that you never reset usedFrameCompleted to false so it never goes into the loop again after the first time and just cascades.

Try to reset that at the end of the ResetIDFrame function and that should give you the behavior you're looking for, or use a local variable instead that could work too.

Comment
Add comment · Show 1 · 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
avatar image usalalas · Nov 21, 2015 at 12:14 PM 0
Share

Thank you @AngryTilde .

Follow this Question

Answers Answers and Comments

35 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 4.6 Button OnClick's Functions not showing. 9 Answers

Constructors 0 Answers

trying to create a tap to fill power bar that appears after destroying game object. 0 Answers

Adding textures to different faces of 3d furniture parts?,Adding texture to only one face of a table 1 Answer

Load Scene Unity by Application.LoadLevelAsync 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges