I made a classic GUI bar that is rounded
My problems is that it keeps on counting even when there is no collision on my trigger.
I want it to count each time there is a collision detected until it reaches a maximum.
Here is my script:
> using UnityEngine;
> using System.Collections;
>
> public class eggcollider : MonoBehaviour {
>
>
> public int theScore = 0;
>
> void Update ()
> {
> renderer.material.SetFloat("_Cutoff",
> Mathf.InverseLerp(100, 0,
> theScore++));
> }
>
>
> void OnTriggerEnter(Collider theCollision)
> {
> GameObject collisionGO = theCollision.gameObject;
>
> if(theCollision.name == "Stone") {
> theScore++;
> }
> }
>
>
> void OnGUI()
> {
> GUILayout.Label("Score: " + theScore);
> }
> }
Also my a noob when it comes to c#.
Please help a fellow game designer.