• 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 /
avatar image
Question by Xision · Jun 01, 2019 at 09:35 PM · setactive

Why is this starting active??

I have no clue why this isn't working. The shop is active when I start play mode. I'm steaming this and no one has any clue. I saved it too, forgot to save for the photo still isn't working

 int points;
 public Text PointsCounter;
 public GameObject doggo;
 public GameObject Shop;
 private bool HasBeenActive;
 private int WorkerLvl = 0;
 int pointsperclick = 1;
 int pointspersecond = 0;
 int WorkerCost;
 int DblMoneyCost;

 void Start()
 {
     doggo.transform.Translate(0, 0, -1);
     points = 0;
     HasBeenActive = false;
     Shop.SetActive(false);
 }

 public void WorkerBtn()
 {
     WorkerLvl += 1;
 }


 void Update()
 {
     PointsCounter.text = points.ToString();
     Debug.Log (points);
     // Button if statements. 
     if (WorkerLvl >= 1)
     {
         points += pointspersecond;

         if (WorkerLvl == 1)
         {
             pointspersecond = 1;
         }
         
     }

     if (Input.GetKeyDown(KeyCode.Mouse0))
     {
         transform.localScale += new Vector3(-0.1f, -0.1f, 0);
         points += pointsperclick;    
     }
     if (Input.GetKeyUp(KeyCode.Mouse0))
     {
         transform.localScale += new Vector3(0.1f, 0.1f, 0);
     }
     if (points >= 100 && HasBeenActive == false);
     {
         Shop.SetActive(true);
         HasBeenActive = true;
     }
     if (HasBeenActive == true)
     {
         Shop.SetActive(true);
     }
 }

}

questions1.png (40.7 kB)
Comment

People who like this

0 Show 0
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

4 Replies

· Add your reply
  • Sort: 
avatar image

Answer by FPSworrior · Jun 02, 2019 at 11:25 PM

How fast are your points going up in Debug.Log? My guess is that your points are going passed 100 almost instantly because its not regulated by a timescale. I think line 34 is where your problems at, your points are up a certain amount every frame which can be very fast. I'd recommend you times your points by Time.deltaTime and see if that helps.

Comment
Xision

People who like this

1 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 Xision · Jun 03, 2019 at 01:12 PM 0
Share

@FPSworrior Alright Ill definitely try that. Ill let you know sometime today. I appreciate it :D

avatar image

Answer by malones · Jun 03, 2019 at 06:21 PM

You have a semicolon after your If Statement in line 51.

alt text


download-8.jpg (8.0 kB)
Comment
Xision

People who like this

1 Show 0 · 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

Answer by surfuay · Jun 01, 2019 at 10:42 PM

is the shop active in your editor? might be as simple as setting it inactive and saving the scene before you hit the play at the top of the editor.

Comment

People who like this

0 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 Xision · Jun 02, 2019 at 09:45 PM 0
Share

@surfuay yeah, it's set inactive, thank god I forgot about this post my code got corrupted lol. I have no clue why it's not working still.

avatar image

Answer by owijo12 · Jun 03, 2019 at 06:58 PM

is the shop active in your editor? might be as simple as setting it inactive and saving the scene before you hit the play at the top of the editor.

if still need help email me (: shaysapozhnikov@gmail.com

Comment

People who like this

0 Show 0 · 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

110 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

Related Questions

Set GUI Text active/inactive by clicking on a button? 2 Answers

add button to switch cars 1 Answer

Can't deactivate activated object 0 Answers

Enabling a disabled Canvas containing a ScrollRect makes the content jump to the bottom 0 Answers

gameObject reappearing after setactive false 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