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 unity_ZN5-c7qJ3wMF7A · Apr 21, 2020 at 12:03 PM · functionactivatefunction call

Public functions not calling and scripts not being set to active

I'm trying to call a public function and set a script to active however neither the script nor the function work when called.`public class CinemaScript : MonoBehaviour { public GameObject[] popcorn; //public GameObject gameCamera; public float spawnInterval = 0.1f; public float gameTimeEnd = 20.0f;

 public float timer = 0;
 public float gameTime = 0;
 private GameObject bucket;
 private leaderBoardScript LBS;
 private achievementScript ACS;

 [SerializeField] private GameObject tutorialObject;
 [SerializeField] private GameObject winScreen;
 [SerializeField] private GameObject loseScreen;

 private bool firstGame = false;

 // Start is called before the first frame update
 void Start()
 {

     bucket = GameObject.Find("Bucket");

     LBS = GetComponent<leaderBoardScript>();
     ACS = GetComponent<achievementScript>();

     // Checking if this is the first game in order to show or not gallery notification if player wins.
     if (PlayerPrefs.GetInt("cinneAch") == 0)
         firstGame = true;
     else
         firstGame = false;
 }

 // Update is called once per frame
 void Update()
 {

     if (GetComponent<achievementScript>() == null || GetComponent<leaderBoardScript>() == null)
     {
         Debug.Log("big BOi erreror");
     }
     if (!tutorialObject.activeSelf && !winScreen.activeSelf)
     {
         if (gameTime < gameTimeEnd)
         {
             gameTime += Time.deltaTime;

             if (bucket.GetComponent<BucketScript>().score < bucket.GetComponent<BucketScript>().scoreLimit)
             {
                 timer += Time.deltaTime;

                 if (timer >= spawnInterval)
                 {
                     Vector2 point = Random.insideUnitCircle.normalized * 10;
                     int popcornPrefab = Random.Range(1, popcorn.Length);
                     Instantiate(popcorn[popcornPrefab - 1], new Vector3(point.x, transform.position.y, point.y), Quaternion.identity);

                     timer = 0;
                 }
             }
             else
             {
                 // The player won. Turning gallery notification on.
                 if (firstGame)
                     GameObject.Find("GalleryNotificationHandler").GetComponent<GalleryNotification>().galleryNotification = true;

                 LBS.cinneworldEnd((int)gameTime);
                 ACS.enabled = true;
                 winScreen.SetActive(true);
             }
         }


Comment
Add comment · Show 3
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 endasil_unity · Apr 21, 2020 at 02:48 PM 0
Share

Is it correct that the player should win if there is time left and score limit has not been reached? If you are not getting any errors I think the most probable cause is that you never get to the part with

LBS.cinneworldEnd((int)gameTime);
ACS.enabled = true;

that i assume you are trying to reach.

Try write a Debug.Log("code reached"); before LBS.cinneworldEnd((int)gameTime);
ACS.enabled = true; and see if you actually reach that part.

avatar image unity_ZN5-c7qJ3wMF7A endasil_unity · Apr 21, 2020 at 06:16 PM 0
Share

WinScreen sets active though which is the weird part about this bug

avatar image endasil_unity unity_ZN5-c7qJ3wMF7A · Apr 23, 2020 at 01:24 PM 0
Share

So set a breakpoint at LBS.cinneworldEnd((int)gameTime); and see if the debuger gets there, then you can try step into the function and see what happens. This should give you the answers to what is happening. :)

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

129 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 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 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 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

Activating function in distant item 0 Answers

How i can make a function call and then after 15 sec another function call during this function call the first one stops.And this process keep repeating again and again. 1 Answer

Function by activate 1 Answer

Function being called on multiple objects when just one is clicked 1 Answer

function that returns multiple variables (in this case, lists) 1 Answer


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