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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by MetalLord · Mar 19, 2012 at 05:32 AM · score

Score going up like crazy

This should work this way : while a object is inside a trigger you press a key to change its material,if it leaves the trigger with the original material you lose points,with the new you win,a bool dont let you press the button infinite times or press at the wrong time.

But when i start the game the score start going up at extreme speeds without reason,in some seconds it already pass the 1000 mark.

 using UnityEngine;
 using System.Collections;
 
 public class teclacima: MonoBehaviour {
 
 public Material[] coisas;
 private static bool esquilo = false;
 
 
     
     
 void Update () {
 if (Input.GetKeyUp("backspace") && esquilo == true) 
 this.renderer.sharedMaterial = coisas[1];
 sistema.ponto += 1;
 esquilo = false;    
     if(sistema.fase == 0)
     
 {
      sistema.score += 1;
     
      
 }
         
     else if(sistema.fase == 1)
     
 {
      sistema.score += 2;
      
 }
 
     else if(sistema.fase == 2)
     
 {
      sistema.score += 3;
      
 }
         
         
 
     else if(sistema.fase == 3)
     
 {
      sistema.score += 4;
      
 }
 
         
 }    
         
         
         
         
 
 void OnTriggerEnter(Collider other) {
 esquilo = true;
     }
         
 void OnTriggerLeave(Collider other) {
 esquilo = false;
 if (this.renderer.sharedMaterial == coisas[0])
 sistema.ponto -= 1;
 
     }
     
     }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Esa · Mar 19, 2012 at 06:18 AM

You oughto wrap the if in curlybracets {} :)

 if (Input.GetKeyUp("backspace") && esquilo == true) 
 {
 this.renderer.sharedMaterial = coisas[1];
 sistema.ponto += 1;
 esquilo = false;   
 }
Comment
Add comment · 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 Kleptomaniac · Mar 19, 2012 at 11:02 AM 0
Share

It's always the simplest things ... :)

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Score not adding? 3 Answers

Score display error 1 Answer

Score system 1 Answer

Setting Scroll View Width GUILayout 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