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.
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,
First script as pickups is required in your project. I always use such script in my thesis writing management tools.