Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 pranav_prabhu · Jan 21, 2014 at 01:26 PM · variableoncequiz

How to make a person answer a question only once

I'm making a game in which a person has to answer questions. I have this code which I have attached to many game objects-:

 private var inRange: boolean = false;
 var myStyle = new GUIStyle();
 static var score:int;
 public var mess: String = "Clue";
 var stringToEdit : String = "Enter Here";
 var finalstring:String="nil";
 function OnTriggerEnter(other:Collider) 
 {
     if (other.tag == "Player")
     {
         inRange =  true;
     }
 }
 
 function OnTriggerExit(other:Collider) 
 {
     if (other.tag == "Player") 
     {
         inRange =  false;
     }
     if(score==5)
     {
         score=5;
     }
 }
 
 function Update(){
      if(finalstring==stringToEdit)
     {
         score=score+5;
         stringToEdit="null";
     }
 }
 
 function Start()
 {
     if(score==5)
     {
         score=5;
     }
 }
 
 function OnGUI () 
 {
     
      if(inRange)
     {
         GUI.Label (Rect (10, 10, 100, 20),"Score: " +score.ToString()); 
         // Make a text field that modifies stringToEdit.
         stringToEdit = GUI.TextField (Rect (10, 50, 1000, 20), stringToEdit, 25);
         GUI.Label (Rect (10, 30, 2000, 1000),"Clue: " +mess,myStyle);
     }
 }
 

The problem is that a person is able to answer a question many times, thus giving him more points. what can i do to make him answer only once

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 Jamora · Jan 21, 2014 at 02:59 PM 0
Share

I see you went with my solution for your previous question here. If you continue using Unity Answers, please mark the correct answer (or answer you end up using) by pressing the checkmark below the thumbs. Also please give a thumbs up (when you have enough karma) to the other helpful answers. I also fixed some code formatting in your question.

Ironically, an answer to your question is: "By not marking their previous correct answers as correct."

avatar image HappyMoo · Jan 21, 2014 at 03:07 PM 0
Share

Waiting for you to accept an answer on your previous question before considering answering here.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sisso · Jan 21, 2014 at 01:39 PM

I think the best solution is change your code to not allow a person don't write twice.

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

21 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

Related Questions

Detecting multiples of 2 3 Answers

Calling an if statement once even when it is calling every frame? 3 Answers

Creating a Multiple Choice Game 2 Answers

Stupid question, but bow do I access a variable that is inside the same object my script is? 2 Answers

Newbie Question Regarding Variables 2 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