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 /
avatar image
1
Question by JamesReubenGruta · Jul 16, 2011 at 06:38 PM · collisionguitriggerpickupcs0103

GUI text like GTA

Hello Everyone! Im new in unity3d and currently working hard for my thesis about 3d vle implementation in our school. I can i pick up an object and then it it gives me amount of points in the other hand the points are displayed in GUI text. Just like in GTA: Vice City that if Tommy picks up money it adds value to the gui text intended for current money. Please help its for my thesis purpose and i am working very hard for it.

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 Peter G · Jul 16, 2011 at 06:47 PM 1
Share

What parts work and don't work right now?

avatar image AVividLight · Jul 16, 2011 at 07:00 PM 1
Share

What do you need help with?

2 Replies

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

Answer by Ziad · Jul 16, 2011 at 07:16 PM

Well, Here is a script i made it may help u, put this script on ur money or whatever u want to pick up

using UnityEngine; using System.Collections;

public class PickUps : MonoBehaviour {

 public Transform Player;

 void Start()
 {
     GameObject Plr;
     Plr = GameObject.Find("Write Ur Character Name Here");
     Player = Plr.transform;
 }
 
 void Update()
 {
     if (Score.Instance.ScorePointsLeft == 0)
         return;
     PickUpWhileTouched();
 }

 void PickUpWhileTouched()
 {
     if (Vector3.Distance(transform.position, UrCharacterName.position) <= 1)
     {
         Score.Instance.ScorePoints += 80;
         Score.Instance.ScorePointsLeft -= 80;
         GameObject.Destroy(gameObject);
     }
 }

}

and put this script on ur player character

using UnityEngine; using System.Collections;

public class Score : MonoBehaviour {

 public GUIStyle mySkin;
 public static Score Instance;

 public Texture2D Win;
 public int ScorePoints = 0;
 public int ScorePointsLeft = 4000;

 void Awake ()
 {
     Instance = this;
 }
 
 void Update ()
 {
 
 }

 public void OnGUI()
 {
     DisplayScore();
     DisplayWin();
 }

 public void DisplayScore()
 {

     GUI.Label(new Rect(10, 10, 100, 20), "Points: " + ScorePoints.ToString());
     GUI.Label(new Rect(10, 30, 300, 20), "Points: " + ScorePointsLeft.ToString());
 }

 public void DisplayWin()
 {
     if (ScorePointsLeft == 0)
     {
         GUI.Label(new Rect(50, 50, 1000, 500), Win);

     }
 }

}

and thats all,.... u should play with the script untile u get what u want,

Comment
Add comment · Show 8 · 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 JamesReubenGruta · Jul 16, 2011 at 07:35 PM 0
Share

Hello there thanks Ziad for the code i really appreciate it! Im just wondering if it the score will cumulatively add in the gui text if for example i pick up 5 items?

avatar image Ziad · Jul 16, 2011 at 07:38 PM 0
Share

When u pick up something the score increace by 80 as i wrote in the script :) and add me if u need more info ziad_khalid@yahoo.com

avatar image JamesReubenGruta · Jul 16, 2011 at 07:43 PM 0
Share

I got the logic thanks! but i jUSt tried and theres an error saying "Assets/zscripts universal/Pickup.cs(18,9): error CS0103: The name `Score' does not exist in the current context " do you encounter that error? Ill add you up later my friend in Yahoo messenger, i just have trouble logging in my account.

avatar image Ziad · Jul 16, 2011 at 07:46 PM 0
Share

U Should name the first script as (PickUps) in ur project tap and the second as (Score) and that should fix the problem

avatar image Ziad · Jul 16, 2011 at 07:48 PM 0
Share

and don't forget to name it in the scripts too

Show more comments
avatar image
0

Answer by franksmith36 · Apr 12, 2012 at 03:16 PM

First script as pickups is required in your project. I always use such script in my thesis writing management tools.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

gameObject.enabled is not working 1 Answer

activate gui on trigger enter 1 Answer

Coin pickup script not working..? 1 Answer

Trigger collision with Player won't work 2 Answers

Mission Objectives 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