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 shona1209 · Mar 30, 2014 at 11:08 PM · 2dspritesscore

Different score for each sprite.

Ok i have this script that works with my enemy script to produce a score, it works, however you get the same score for each sprite however i want to change how much you score when you click on each different sprite so that you could lose points if you kill the wrong thing. Can any point me in the right direction thanks

 using UnityEngine;
 using System.Collections;
 
 public class GameManager : MonoBehaviour 
 {
     public GameObject Cursor;
 
     public GUISkin theskin;
     //Total number of hits
     public int Hits = 0;
     public GameObject badger;
     public GameObject cow;
     //Hit Limit needed to win
     public int WinHits = 1000;
 
 
     //Time limit
     public float TimeLimit = 60.0f;
     
     public SpriteRenderer WinObj = null;
     
     public SpriteRenderer LoseObj = null;
     
     // Use this for initialization
     void Start () 
     {   
         StartCoroutine(CheckWin());
     }
     
     // Update is called once per frame
     void Update () 
     {
         //Update cursor position
         Cursor.transform.position = new Vector3(Input.mousePosition.x - (Screen.width/2),Input.mousePosition.y - (Screen.height/2),0);
     }
 
 
 
         void OnGUI () {
 
         GUI.skin = theskin;
 
         GUI.Label (new Rect (500, 13, 100, 100), "" + 100*Hits);
         
 
     }
         IEnumerator CheckWin()
     {
         yield return new WaitForSeconds(TimeLimit);
 
         //Check for win
         if(100*Hits >= WinHits)
         {
             //Show game win message
             WinObj.GetComponent<SpriteRenderer>().enabled = true;
         }
         else
         {
             //Show game lose message
             LoseObj.GetComponent<SpriteRenderer>().enabled = true;
         }
 
 }
     public void Hit()
     {
         if (badger) {
         Hits --;
         }
         else if (cow){
             Hits ++;
         }
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

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

20 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

Related Questions

Sprite Based Score Rendering 1 Answer

Is there any benefit to slicing in power of two dimensions inside a sprite sheet? 1 Answer

Get sprites from a Texture2D 1 Answer

1px Gap Between 2D Sprites 2 Answers

Animating a Sprite from Parent Animator 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