- Home /
Scoresystem wont function correctly
Hi everyone
i hope you can help me move a little further on this, iam creating a game where the player can shoot zombies with a sniper rifle, and i then want to make a score system that gives 10 points when a zombie is shot....
The points is counting, but is there anyway i in the End Scene can show the points in the middle of the screen, i guess in a new GUI?
Im no coder, but iam trying to understand it, so any help would be appreciated!! this one is killing me....
Also in the end scene i have a text gui you can click to Retry the first level, but then a New point counter is overlapping the old one... is there anyway to get rid of the old Point Counter?
Here is my code so far, Yeah you may laugh, but iam really wanna try figure this out :-)
var score : int = 0;
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
function OnGUI() {
var myStyle : GUIStyle = new GUIStyle();
myStyle.fontSize = 22;
myStyle.normal.textColor = Color.white;
GUI.Label(Rect(30, 30, 200, 300), "Points:" + score,myStyle);
}
function Update () {
if (Input.GetMouseButtonDown(0)) {
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit)) {
print ("Hit something: "+hit.collider.name);
if (hit.collider.tag == "Enemy") {
score += 10;
Debug.Log("Scored again! :"+score);
}
}
}
}
Your answer
Follow this Question
Related Questions
How to create a point/score system based on player performance. 2 Answers
On screen scoring in multiplayer 1 Answer
GUI Text Score counter 3 Answers
to string. 4 Answers
Help! Why doesn't this work? GUI/Static vars Help! Javascript 1 Answer