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
1
Question by Namiic · May 15, 2019 at 02:35 PM · scripting problemmathloopgenerator

How do I get this code to run specified amount of times

What I am trying to do is make a math question generator, once an object is disabled. I want a new equation to appear each time the user inputs the correct answer. I want it to run a specified amount of time, but I can only either get it to run once, or unlimited

This is what I have come up with so far

alt text

I know I did not word this that well, but im basically asking, how do I get the question generator to appear a set period of time, with new equation once a specific object is destroyed.

capture.png (33.0 kB)
Comment
Add comment · Show 4
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 IamAnewUser · May 15, 2019 at 04:22 PM 0
Share

Let's find out what exactly you want :
1)How many GameObjects with the Text component and with the tag "equations" exist in your scene?
2)Can you share the your Disable() method

avatar image Namiic IamAnewUser · May 15, 2019 at 04:27 PM 0
Share

Disable() is the sd.png located on the bottom, both images are for the other parts of the script

g.png (36.0 kB)
sd.png (34.4 kB)
avatar image Namiic IamAnewUser · May 15, 2019 at 04:29 PM 0
Share

only 1 component is tagged equation which is for the text box

the text box shows the equation needed to be solved

ex 1+1 would show in the text box

avatar image Namiic IamAnewUser · May 15, 2019 at 04:36 PM 0
Share

the object doesn't get destroyed, just disabled.

The code works for the question generator to appear, but you can only answer 1 problem then the generator disappears and you go back to the other part of the game, I need it to have the user enter for example like 3 questions then the generator can disappear and continue the game

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by IamAnewUser · May 15, 2019 at 04:43 PM

I'm guessing you want three questions displayed (each one after the previous has been answered correctly) and not to generate three times a question in a single frame, right?


In this case you have to
*create int correctAnswered = 0 at the start of your script
*remove the for loop entirely from QuestionAnswerInput() and replace it with this instead

 //amountOfQuestionsYouWantToBeDisplayed could be for example 3 for three questions
 correctAnswered ++;
 if(correctAnswered < amountOfQuestionsYouWantToBeDisplayed){
     QuestionGen();
 }else{
     correctAnswered = 0;
     //do what you want to end the questions here
 }

Hope this helps

Comment
Add comment · Show 5 · 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 Namiic · May 15, 2019 at 04:52 PM 0
Share

Yes it worked THAN$$anonymous$$S so much, just needed to add correctAnswered++; before the the QuestionGen(); and that solution worked

I really appreciate the help, was trying to figure this out for like 2 hours <3

avatar image IamAnewUser Namiic · May 15, 2019 at 05:05 PM 0
Share

You got to put it before the if(like in the answer) or it will display one less question

avatar image Namiic IamAnewUser · May 15, 2019 at 05:17 PM 0
Share

ok, will adjust that then, thanks again

avatar image IamAnewUser · May 15, 2019 at 04:53 PM 0
Share

Don't forget the correctAnswered++;(I did)

avatar image Namiic IamAnewUser · May 15, 2019 at 04:55 PM 0
Share

yes i got that

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

114 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

Related Questions

Need help rendering Orbits, with Orbital Elements 1 Answer

How would I make a math generator when I press space on a specified object? 1 Answer

How to add multiples variable ints from a foreach loop 1 Answer

How to get the "Perfect" Sine Wave Pattern 2 Answers

My Animation Loops 3/4 of the way through 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