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_0sdsWZad6Fwp-A · Nov 20, 2018 at 01:16 AM · mathif-statementsienumeratorelseequation

Any Ideas on how to solve this?

I am relatively new to coding and unity and I was following a guys tutorials on how to make a clicker style game. His code on one of his videos were very buggy and it would always go into the negative if you bought an auto seller, which is an update in the game. I fixed all of bugs that would put you in negative but I am stuck trying to find out a way to solve another bug. What I am currently using is an IEnumerator function with if statements inside. The bug that I am facing is when you hire sellers that sell the ore and they are trying to sell an amount that is bigger than is being made. What happens is it takes away the ore, but it does not credit you for only selling partial of what the miners sell every second. I am trying to find a way that it can sell the amount of ores that is < than the number of sellers. I tried doing an if and else statement inside of another else statement but it freezes all of my code that is inside of the IEnumerator and I am confused on how to fix this. Anyone have an idea on how to fix this issue?

Comment
Add comment · Show 1
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 Cornelis-de-Jager · Nov 20, 2018 at 01:54 AM 0
Share

please post code.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unity_0sdsWZad6Fwp-A · Nov 20, 2018 at 02:24 AM

@Cornelis-de-Jager here: using System.Collections; using System.Collections.Generic; using UnityEngine;

public class AutoSell : MonoBehaviour {

 public bool SellingOre = true;
 public static int CashIncrease = 1;
 public int InternalIncrease;

 void Update()
 {
     CashIncrease = GlobalShop.shopPerSec;
     InternalIncrease = CashIncrease;
     if (SellingOre == false)
     {
         SellingOre = true;
         StartCoroutine(SellTheOre());
     }

 }

 IEnumerator SellTheOre()
 {
     if (GlobalOres.OreCount < InternalIncrease)
     {
         SellingOre = false;
         GlobalOres.OreCount = GlobalShop.shopPerSec;
         if (GlobalOres.OreCount < 1) ;
         {
             SellingOre = true;
         }

     } 
     else
         GlobalCash.CashCount += InternalIncrease;
     GlobalOres.OreCount -= GlobalShop.shopPerSec;
     yield return new WaitForSeconds(1);
     SellingOre = false;


 }

}

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

Follow this Question

Answers Answers and Comments

101 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

Related Questions

Circular motion via the mathematical circle equation? 4 Answers

RigidBody 2D x velocity function 1 Answer

if statement for 6 ints help C# 2 Answers

Making slider match health when values are different. 0 Answers

If statement always true 3 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