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 kyly1992 · Jun 08, 2014 at 03:21 PM · movementloopscore

How can i make score keep updating after bool condition has been met on looping objects?

So my problem is i have a score that updates by 10points after the objects pass a specific coordinate. The thing is i have to objects to loop back to the starting poistion after they reach a certain coordinate so they can be run again. The thing is when they reach the score point nothing happens, an my guess is that it is becuase they pass the point once already, heres a script to help

 using UnityEngine;
 using System.Collections;
 
 public class scoredisplay : MonoBehaviour {
     public static int scoreValue;
     public GUIText guiScore;
     private Transform Obstacle;
     bool hasAwardedPoints = false;
 
 
 
 
 
 
     void Awake() {
         DontDestroyOnLoad (gameObject);
     }
 
 
 
 
 
     // Use this for initialization
     void Start () {
 
 
 
         Obstacle = transform;
         scoreValue = 0;
         guiScore.text = "Score: 0";
 
 
         }
         
 
 
 
 
 
     // Update is called once per frame
         void Update () {
         if (Obstacle.position.x < -12.5f && !hasAwardedPoints) {
                         scoreValue += 10;
                         guiScore.text = "Score: " + scoreValue;
                         hasAwardedPoints = true;
                 }
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 kyly1992 · Jun 08, 2014 at 03:10 PM 0
Share

any help would be appreciated

1 Reply

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

Answer by robusto · Jun 08, 2014 at 03:56 PM

Where you reset the position of object, that is where you need to reset the hasAwardedPoints back to false. If you are using MonoDevelop you can right click hasAwardedPoints where you declared it at the top of this script and click refactor and click Create Property so it will give you a getter/setter which can be modified from another script that I presume is resetting the object's position.

Comment
Add comment · Show 3 · 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 kyly1992 · Jun 08, 2014 at 11:37 PM 0
Share

ok when i do as you say it gives me the option to select up/down to pick new location, not sure what to do from there

avatar image kyly1992 · Jun 08, 2014 at 11:39 PM 0
Share

not sure what to do when it says select up/down for new location and how do i modify it from another script afterwards

avatar image kyly1992 · Jun 11, 2014 at 06:13 PM 0
Share

found it out thnx

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

22 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

Related Questions

Move a Person to a point / Repeat a function called from another script? 1 Answer

every x points, object speed increases 1 Answer

How do you make your game have moves count down to end the game? 1 Answer

Check Coordinate if its increasing by value over time 1 Answer

Movement Script Help 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