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 /
avatar image
0
Question by Dragonfly3r · Nov 17, 2016 at 08:07 PM · c#collisionfadeopacitycheckpoints

Opacity text freeze bug

So I have a checkpoint system which providing the player has the atleast 1 of an object then it will be able to activate a checkpoint. When discovering / activate checkpoints there will be a numerous amount of messages which will have their opacity fade in / out

However I have noticed a bug that shows up only when if a player activates a checkpoint.

When the player discovers a checkpoint it will display the message "Checkpoint discovered \n Press F to activate" if the player activates the checkpoint it will display the message "Checkpoint Activated"

Now what should happen is when the checkpoint discovered mesage appears it should fade out and the checkpoint activated message should fade in.

If the player presses the F button faster than the message fading out then it should fade out faster and fade in the activated message.

However instead if the player press the F button to activate checkpoint whilst the discovered checkpoint message is fading out then the checkpoint activated message will get stuck at the opacity level that checkpoint discovered message was stopped at and will then ignore all fade in / outs for all messages until a new checkpoint is discovered and then it will reset the opacity back to normal.

You can also see that if a message has been displayed such as "can't activate checkpoint again" or "checkpoint discovered" once it has been displayed it won't display any additional times (I want it to display additional times) but instead only the once.

See gif link below for bug (messages appear at top of image) http://im2.ezgif.com/tmp/ezgif.com-d83d3b3465.gif

Code for checkpoint system is below:

  public static int _currentMatches = 3;
     private float speed = 1f;
 
     public bool inZone = false;
     private bool triggered = false;
 
     public Text matches_text;
     public Text _HUD_Text;
     public CanvasGroup canvasGroup = null;
 
     public LevelManager levelManager;
 
     void Start()
     {
         levelManager = FindObjectOfType<LevelManager>();
         matches_text.text = "X " + _currentMatches;
         _HUD_Text.text = " ";
     }
     void Update()
     {
         if (Input.GetKeyDown(KeyCode.F) && inZone && levelManager.currentCheckpoint != gameObject)
         {
             StopCoroutine("Opacity");
             triggered = false;
             if (_currentMatches >= 1)
             {
                 levelManager.currentCheckpoint = gameObject;
                 gameObject.GetComponentInChildren<ParticleSystem>().Play();
                 gameObject.GetComponentInChildren<Light>().enabled = true;
                 _currentMatches--;
                 matches_text.text = "X " + _currentMatches;
                 StartCoroutine("Opacity");
                 _HUD_Text.text = "Checkpoint Activated";
             }
             else if (_currentMatches <= 0)
             { _currentMatches = 0; }
         }
         if (inZone && levelManager.currentCheckpoint != gameObject)
         {
             _HUD_Text.text = "Checkpoint Discovered \nPress F to activate";
             StartCoroutine("Opacity");
         }
 
         if (!inZone && levelManager.currentCheckpoint != gameObject)
         {
             gameObject.GetComponentInChildren<ParticleSystem>().Stop();
             gameObject.GetComponentInChildren<Light>().enabled = false;
         }
         if (inZone && levelManager.currentCheckpoint != gameObject && _currentMatches == 0)
         {
             _HUD_Text.text = "No Matches To Activate Checkpoint \nGo Find Some";
             StartCoroutine("Opacity");
         }
     }
     IEnumerator Opacity()
     {
         if (!triggered)
         {
             triggered = true;
             if (canvasGroup.alpha == 1)
             {
                 canvasGroup.alpha = 0;
             }
             yield return FadeIn();
             yield return new WaitForSeconds(1f);
             yield return FadeOut();
             triggered = false;
         }
     }
 
     IEnumerator FadeIn()
     {
         while (canvasGroup.alpha < 1)
         {
             canvasGroup.alpha += Time.deltaTime * speed;
             yield return null;
         }
     }
 
     IEnumerator FadeOut()
     {
         while (canvasGroup.alpha > 0)
         {
             canvasGroup.alpha -= Time.deltaTime * speed;
             yield return null;
         }
     }
     public void OnTriggerEnter(Collider other)
     {
         if (other.name == "Player")
         {
             inZone = true;
             if (levelManager.currentCheckpoint == gameObject)
             {
                 _HUD_Text.text = "Can't Activate Checkpoint Again";
                 StartCoroutine(Opacity());
             } 
         }
     }
     public void OnTriggerExit(Collider other)
     {
         if (other.name == "Player")
         { inZone = false; }
     }
     public void AddMatches(int _matchesAmount)
     {
         _currentMatches += _matchesAmount;
         matches_text.text = "X " + _currentMatches;
     }
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

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

2D collisions in Unity 4.3? 1 Answer

Coins work in engine but not on phone 0 Answers

How to move an object over a distance in a direction? 2 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