- Home /
Question by
knowlife4 · Apr 22, 2016 at 05:24 AM ·
javascriptguitrigger
Basketball Score counter
I'm Making A basketball game, And My Scripts Aren't Working! Please Help, Its Not Counting The Points. PS: I'm New To Scripting
#pragma strict
static var Score : int = 0;
function OnGUI () {
GUI.Box (Rect (10, 10, 100, 90), "Score: " + Score);
}
This Is Connected To An Empty Game Object, And Seems To Be Working.
#pragma strict
var Basket = 1;
function OnTriggerEnter (info : Collider)
{if (info.tag == "Ball")
{Score.Score += Basket;
}
}
This Is Connected To My Trigger.
Thanks A Head Of Time, Knowlife4
Comment
Answer by makaka-org · Oct 26, 2019 at 12:32 PM
Unity Script is deprecated (C# is used now), but anyway your Ball must have "Ball" tag in this case, which can be assign in top of inspector.
Also, take a look on this complete asset: Basketball Game 3D. Hope, it helps.
Your answer
Follow this Question
Related Questions
LoadLevel Health Question. 1 Answer
Showing text near object 1 Answer
Setting Scroll View Width GUILayout 1 Answer