- Home /
simple score system
im sorry for this question but i must to ask. cause i tried many times.
can someone help me ? about simple score system ?
there will be a ball. when the ball touched the box. the counter will count 3 seconds. then score +1000 and levelup,
You should try to write the code yourself first, then bring back the code that doesn't work when you encounter problems. If you don't know how to program, then search around for some Unity scripting tutorials and, optionally, some general program$$anonymous$$g tutorials. Occasionally, someone actually posts ready-to-use code for things like this, but they really shouldn't, because you won't learn anything from it. :)
For starters:
Study how to declare variables and set their values.
Next, study how to keep track of time in Unity. (The functions in Time, i.e. Time.deltaTime in particular)
Next, take a look at Triggers and Collisions (for when the ball touches).
When you understand the mechanics behind these three things, you should know enough to construct the score system you've described. The good thing is that your score system is well-designed for a beginning project because it is realistically simple, so you're more likely to accomplish it and not get frustrated. That's good. :)
Answer by syclamoth · Oct 28, 2011 at 09:17 AM
float score = 0; int level = 0;
IEnumerator WaitThenScore(flaot waitTime) { yield return new WaitForSeconds(waitTime); score += 1000; level++; }
void OnCollision(Collision collision) { if(however you determine that it is the box) { StartCoroutine(WaitThenScore(3)); } }
There you go.
Honestly, how hard can a scoring system be?
tsk tsk, Sycla. Now he's gonna do something like copy-paste that into a js-file, and come back with 50 compiler errors. Teach a man to fish, and...
Well, I could have written it in JS, but that'd just be making it too easy, wouldn't it.
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."
Is that not how that goes?
Answer by ishan0103 · Dec 25, 2015 at 01:03 AM
use a gui system dude sort of this way
static var score : int = 0;
function OnGUI () { GUI.Box (Rect (10, 50, 90, 40), ("score: " + score)); }
then use an OnTriggerEnter function to update this var called score how was my answer btw
Your answer
