Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 CoderBear · May 28, 2013 at 12:10 AM · c#android

Weird issue with first-time effect call on Android

It is hard to phrase the question above. I have a spawn system set up that works and works effectively.

There is a special effect that effects the spawn system from time to time. The wierd thing is that in the editor it functions without issue, everytime. How ever the first time this effect is triggered on Android the effect doesn't happen. Yet every time subsequent to that it works flawlessly. I have no idea why it is happening but it is frustrating to say the least. I will include my log and code below.

LogCat:

``` 05-27 14:08:33.091: I/Unity(18995): AAUNITY/GAME Fast Apples games played: 1 05-27 14:08:38.391: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:08:39.371: I/Unity(18995): AAUNITY/GAME Current combo count: 2 05-27 14:08:42.391: I/Unity(18995): AAUNITY/GAME Current combo total: 1 05-27 14:08:42.391: I/Unity(18995): AAUNITY/GAME Current game combo total: 1 05-27 14:08:44.381: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:08:46.352: I/Unity(18995): AAUNITY/GAME Gold Apple Caught 05-27 14:08:46.352: I/Unity(18995): AAUNITY/GAME Now activating Gold Effect 05-27 14:08:46.371: I/Unity(18995): AAUNITY/GAME Index 2: Super Frenzy 05-27 14:08:46.411: I/Unity(18995): AAUNITY/GAME Current Effect Before:NONE 05-27 14:08:46.411: I/Unity(18995): AAUNITY/GAME Current Effect After:SUPERFRENZY 05-27 14:08:46.421: I/Unity(18995): AAUNITY/GAME now adding to achievements 05-27 14:08:46.431: I/Unity(18995): AAUNITY/GAME now switching on/ Gold effect 05-27 14:09:06.441: I/Unity(18995): AAUNITY/GAME Gold Apple Caught 05-27 14:09:06.441: I/Unity(18995): AAUNITY/GAME Now activating Gold Effect 05-27 14:09:06.441: I/Unity(18995): AAUNITY/GAME Index 2: Super Frenzy 05-27 14:09:06.441: I/Unity(18995): AAUNITY/GAME Current Effect Before:NONE 05-27 14:09:06.451: I/Unity(18995): AAUNITY/GAME Current Effect After:SUPERFRENZY 05-27 14:09:06.451: I/Unity(18995): AAUNITY/GAME now adding to achievements 05-27 14:09:06.451: I/Unity(18995): AAUNITY/GAME now switching on/ Gold effect 05-27 14:09:06.561: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:06.751: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:06.961: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:07.151: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:07.371: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:07.571: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:07.751: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:07.901: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:09:07.951: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:08.161: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:08.331: I/Unity(18995): AAUNITY/GAME Current combo count: 2 05-27 14:09:08.361: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:08.551: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:08.581: I/Unity(18995): AAUNITY/GAME Current combo total: 1 05-27 14:09:08.581: I/Unity(18995): AAUNITY/GAME Current game combo total: 4 05-27 14:09:08.761: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:08.861: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:09:08.961: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:09.151: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:09.361: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:09.561: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:09.751: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:09.931: I/Unity(18995): AAUNITY/GAME Current combo count: 2 05-27 14:09:09.961: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:10.161: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:10.241: I/Unity(18995): AAUNITY/GAME Current combo total: 2 05-27 14:09:10.251: I/Unity(18995): AAUNITY/GAME Current game combo total: 5 05-27 14:09:10.371: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:10.561: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:10.641: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:09:10.761: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:10.961: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:11.111: I/Unity(18995): AAUNITY/GAME Current combo count: 2 05-27 14:09:11.161: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:11.371: I/Unity(18995): AAUNITY/GAME Super Frenzy Currently Active 05-27 14:09:11.701: I/Unity(18995): AAUNITY/GAME Current combo total: 3 05-27 14:09:11.701: I/Unity(18995): AAUNITY/GAME Current game combo total: 6 05-27 14:09:13.451: I/Unity(18995): AAUNITY/GAME Current combo count: 1 05-27 14:09:14.291: I/Unity(18995): AAUNITY/GAME Current combo count: 2 ```

Spawning code:

 void SpawnNormalApple()
 {
     //add to gold and combo counters
     comboCounter++;
     goldCounter++;
 
     Vector3 spawnPos = transform.position + new Vector3((float)spawns[0], 0, 0);
     spawns.RemoveAt(0);
 
     switch (goldScript.CURRENT_EFFECT)
     {
         case AppleCollider.GOLD_EFFECTS.FRENZY:
             Debug.Log("AAUNITY/GAME Frenzy Currently Active");
             if (random.Next(100) < 50)
             {
                 Instantiate(comboPrefab1, spawnPos, Quaternion.identity);
             }
             else
             {
                 Instantiate(comboPrefab2, spawnPos, Quaternion.identity);
             }
             break;
         case AppleCollider.GOLD_EFFECTS.SUPERFRENZY:
             Debug.Log("AAUNITY/GAME Super Frenzy Currently Active");
             if (random.Next(100) < 50)
             {
                 Instantiate(comboPrefab1, spawnPos, Quaternion.identity);
             }
             else
             {
                 Instantiate(comboPrefab2, spawnPos, Quaternion.identity);
             }
             break;
         case AppleCollider.GOLD_EFFECTS.REPEL:
             Debug.Log("AAUNITY/GAME Repel Currently Active");
             Instantiate(applePrefab, spawnPos, Quaternion.identity);
             break;
         default:
             //            Debug.Log ("AAUNITY/GAME No Gold Effects active or Gold Effect == Double Points");
             if (random.Next(100) > 80)
             {
                 Instantiate(rottenPrefab, spawnPos, Quaternion.identity);
             }
             else
             {
                 Instantiate(applePrefab, spawnPos, Quaternion.identity);
             }
             break;
     }
 
     if (spawns.Count == 0)
         refillSpawns();
 
     if ((comboCounter == 5) && (goldCounter != 50))
     {
         comboCounter = 0;
         SpawnComboApple();
     }
     else if (goldCounter == 50)
     {
         comboCounter = 0;
         SpawnComboApple();
         goldCounter = 0;
         SpawnGoldApple();
     }
 }

effects code:

 private void activateEffect()
 {
     string itemId = "";
     goldEffectActive = true;
     MersenneTwister random = new MersenneTwister();
     int index = random.Next(1,4);
 
     switch (index)
     {
         case 1:
             Debug.Log("AAUNITY/GAME Index " + index + ": Frenzy");
             if (firstCatch)
             {
                 animGold.gameObject.SetActive(true);
                 animGold.Play("Frenzy");
 
                 // The delegate is used here to return to the previously
                 // playing clip after the "hit" animation is done playing.
                 animGold.animationCompleteDelegate = AnimFinishedDelegate;
             }
             break;
         case 2:
             Debug.Log("AAUNITY/GAME Index " + index + ": Super Frenzy");
             if (firstCatch)
             {
                 animGold.gameObject.SetActive(true);
                 animGold.Play("Super Frenzy");
 
                 // The delegate is used here to return to the previously
                 // playing clip after the "hit" animation is done playing.
                 animGold.animationCompleteDelegate = AnimFinishedDelegate;
             }
             break;
         case 3:
             Debug.Log("AAUNITY/GAME Index " + index + ": Double Points");
             if (firstCatch)
             {
                 animGold.gameObject.SetActive(true);
                 animGold.Play("Double");
 
                 // The delegate is used here to return to the previously
                 // playing clip after the "hit" animation is done playing.
                 animGold.animationCompleteDelegate = AnimFinishedDelegate;
             }
             break;
         case 4:
             Debug.Log("AAUNITY/GAME Index " + index + ": Repellent");
             if (firstCatch)
             {
                 animGold.gameObject.SetActive(true);
                 animGold.Play("Repellent");
 
                 // The delegate is used here to return to the previously
                 // playing clip after the "hit" animation is done playing.
                 animGold.animationCompleteDelegate = AnimFinishedDelegate;
             }
             break;
     }
 
     // set the item id for the store invetory retrival
     switch (index)
     {
         case 1: // Frenzy
             Debug.Log("AAUNITY/GAME Current Effect Before:" + CURRENT_EFFECT);
             CURRENT_EFFECT = GOLD_EFFECTS.FRENZY;
             Debug.Log("AAUNITY/GAME Current Effect After:" + CURRENT_EFFECT);
             itemId = AndysApplesAssets.FRENZY_GOOD.ItemId;
             break;
         case 2: // Super Frenzy
             Debug.Log("AAUNITY/GAME Current Effect Before:" + CURRENT_EFFECT);
             CURRENT_EFFECT = GOLD_EFFECTS.SUPERFRENZY;
             Debug.Log("AAUNITY/GAME Current Effect After:" + CURRENT_EFFECT);
             itemId = AndysApplesAssets.SUPER_GOOD.ItemId;
             break;
         case 3: // Double Points
             Debug.Log("AAUNITY/GAME Current Effect Before:" + CURRENT_EFFECT);
             CURRENT_EFFECT = GOLD_EFFECTS.DOUBLE;
             Debug.Log("AAUNITY/GAME Current Effect After:" + CURRENT_EFFECT);
             itemId = AndysApplesAssets.DOUBLE_GOOD.ItemId;
             break;
         case 4: // Repellent
             Debug.Log("AAUNITY/GAME Current Effect Before:" + CURRENT_EFFECT);
             CURRENT_EFFECT = GOLD_EFFECTS.REPEL;
             Debug.Log("AAUNITY/GAME Current Effect After:" + CURRENT_EFFECT);
             itemId = AndysApplesAssets.REPELLENT_GOOD.ItemId;
             break;
     }
     Debug.Log("AAUNITY/GAME now adding to achievements");
     achievementTracker.AddProgressToAchievement("Gold Standard", 1.0f);
 
     if (firstCatch)
     {
         firstCatch = !firstCatch;
         spawnScript.firstCatchGold();
     }
 
     GE_INDEX = index;
     Debug.Log("AAUNITY/GAME now switching on/ Gold effect");
     switch (CURRENT_EFFECT)
     {
         case GOLD_EFFECTS.FRENZY:
             achievementTracker.AddProgressToAchievement("Frenzy Fanatic", 1.0f);
             achievementTracker.AddProgressToAchievement("Fred's Frenzy Bonanaza", 1.0f);
             if (StoreInventory.GetGoodUpgradeLevel(itemId) < 6)
                 effectTimer += StoreInventory.GetGoodUpgradeLevel(itemId);
             else
                 effectTimer += 5;
             break;
         case GOLD_EFFECTS.SUPERFRENZY:
             achievementTracker.AddProgressToAchievement("Raining Combos", 1.0f);
             achievementTracker.AddProgressToAchievement("Super Frenzy Wizard", 1.0f);
             incrementSuperFrenzyAchievements();
             if (StoreInventory.GetGoodUpgradeLevel(itemId) < 6)
                 effectTimer += StoreInventory.GetGoodUpgradeLevel(itemId);
             else
                 effectTimer += 5;
             break;
         case GOLD_EFFECTS.DOUBLE:
             achievementTracker.AddProgressToAchievement("Twice The Charm", 1.0f);
             achievementTracker.AddProgressToAchievement("2X Mastery", 1.0f);
             if (StoreInventory.GetGoodUpgradeLevel(itemId) < 6)
                 effectTimer += StoreInventory.GetGoodUpgradeLevel(itemId);
             else
                 effectTimer += 5;
             break;
         case GOLD_EFFECTS.REPEL:
             achievementTracker.AddProgressToAchievement("Honor System", 1.0f);
             achievementTracker.AddProgressToAchievement("No No to Rottens", 1.0f);
             if (StoreInventory.GetGoodUpgradeLevel(itemId) < 6)
                 effectTimer += StoreInventory.GetGoodUpgradeLevel(itemId);
             else
                 effectTimer += 5;
             break;
         default:
             break;
     }
     Invoke("deactivateEffect", (float)effectTimer);
 }
 
 public void deactivateEffect()
 {
     GE_INDEX = 0;
     LAST_EFFECT = CURRENT_EFFECT;
     CURRENT_EFFECT = GOLD_EFFECTS.NONE;
     goldEffectActive = false;
     effectTimer = 5;
 }

update 5/28/13: OK this is wierd but despite this code that sets the effect timer to 5.

 void Start()
 {
      // Code above this
      effectTimer = 5;
      // ... more code
 }

When run on android device it will set the effectTimer to an initial value of 0. As proved by the following log statement ``` 05-28 12:16:31.041: I/Unity(20876): AAUNITY/GAME Effect timer length for Gold Effect FRENZY is 0 seconds. ```

so I just set an if statement to check for this on the first time only and set it back to its default time and that solved the issue. Still have no idea why this was the case, nor why it only occurred on Android.

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

13 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

Related Questions

Distribute terrain in zones 3 Answers

Calling an android method from Unity3D with a JAR plugin 0 Answers

Procedural Spawning Theorems 0 Answers

C++ windows DLL and Android? 1 Answer

Smooth Follow Camera Rotate on Z-Axis? 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