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 /
  • Help Room /
avatar image
0
Question by PercyPersonal · Feb 01, 2020 at 09:45 PM · gameplayquiz

Reload question generator each time button pressed

Hey, so i have a button which i press in my game which fires up a question generator quiz for the player to answer, and if they get it right they activate another button for single usage as an attack(if they get it wrong they miss a go)...if they answer questions correctly they earn the one off attack option..

...but it seems once i've done this once i can't then load the questions up again, i've tried calling it as a prefab, tried making it just inactive then active each time, tried restarting the script attached to it each time...no such luck...any ideas? Should i set the question generator as a separate scene which is called and then unloaded each time? but if that's the case would that then delete my current scene and also affect performance?

Comment
Add comment · Show 2
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 tormentoarmagedoom · Feb 02, 2020 at 06:25 PM 0
Share

Hello there.

you are doing something wrong. But we need to se screenshots and code to know what. Do NOT need diferent scenes at all.

What you mean with can't then load the questions up again? You need to talk correctly. Its a Canvas? Its a Camera? its a Scene GameObject...? What.

avatar image PercyPersonal · Feb 03, 2020 at 08:42 AM 0
Share

below are the two main scripts for this...any help would be super appreciated and i'll have to credit you when i finally finish this :)

Battle System - when attack button pressed - launches game controller which launches $$anonymous$$i quiz (i've skipped the non relevant parts otherwise it makes it too long)

     //must answer questions to use attack
     public void OnAttackButton()
     {
         if (state != BattleState.PLAYERTURN)
             return;
         // quizCentre.SetActive(true); // (possibly solution 1)
         Instantiate(quizPrefab);  //(possible solution 2)
     }

``` public void WonRound() { realAttackButton.SetActive(true); fakeAttackButton.SetActive(false); //*** Destroy(gameController); }

//real attack button launches this method public void OnAttackEarnt() { StartCoroutine(PlayerAttack()); realAttackButton.SetActive(false); fakeAttackButton.SetActive(true); //gameController.enabled = false; //toggle this script to re-invoke it //gameController.enabled = true; //toggle this script to re-invoke it } } ```

game controller script: (again i've removed the non relevant parts to this issue)

``` public BattleSystem BattleScript; // public GameObject questionDisplay; // public GameObject roundEndDisplay; ``` public void AnswerButtonClicked(bool isCorrect) { if (isCorrect) { playerScore += currentRoundData.pointsAddedForCorrectAnswer;
// If the AnswerButton that was clicked was the correct answer, add points scoreDisplay.text = playerScore.ToString(); } else { LoseAttack(); } if (questionPool.Length > questionIndex + 1) // If there are more questions, show the next question { questionIndex++; ShowQuestion(); } else // If there are no more questions, the round ends { EarnAttack(); } }

 //run the attack enemy routine
 public void EarnAttack()
 {
     isRoundActive = false;
     dataController.SubmitNewPlayerScore(playerScore);
     BattleScript.WonRound();


 }
 // end questions, update score and skip go so enemy can now attack you
 public void LoseAttack()
 {
     isRoundActive = false;
     dataController.SubmitNewPlayerScore(playerScore);
    // questionDisplay.SetActive(false);
     BattleScript.SkipGo();

 }



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

193 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Win condition for both players being on a separate specific positions? 0 Answers

Vector2.up stops working after jumping a few times? 0 Answers

Quiz game - How to go about allowing users to input their own questions. 1 Answer

The star will only show if i got 100 points which is my goal I tried anything but it doesnt work, can someone help me? 1 Answer

please help me. i want to make simillar game like Snotput. the link is given below. 0 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