- Home /
adjustable point limit
At the moment for my kill confirmed style script that each player has their own variant off there is a fixed point limit of 10 points that the player must achieve what I want to do is add a point limit float variable that I can adjust in the menu scene with a slider or buttons How would I achieve this?
here is the script:
 public class tokenscoring : MonoBehaviour {
 
 
 
     public Text MyText;
     private int score;
 // add adjustable point limit variable here
 
     // Use this for initialization
     void Start () {
 
         MyText.text = "";
 
     }
 
 
     // Update is called once per frame
     void Update () {
 
         MyText.text = "" + score;
 
     }
 
 
     void OnCollisionEnter (Collision col)
     {
         if (col.gameObject.tag == "point") {
             score = score +1;
         }
 //change this to whatever the max point limit is
         if (score >= 10) {
             SceneManager.LoadScene(7);
         }
     }
 
 
 }
 
 
Answer by TeohRIK · Mar 13, 2018 at 06:35 AM
The easiest is use Unity Canvas Slider. Its a UI tool. You can set the minimum and maximum float value for the slider within the inspector.
Here the manual: https://docs.unity3d.com/Manual/script-Slider.html
So everytime the slider value change you update the float value.
Your answer
 
 
             Follow this Question
Related Questions
How to fix this Score UI problem 2 Answers
Score & High Score logic doesn't work 2 Answers
points system gets overrwriten 3 Answers
Score counter breaking after adding points 2 Answers
Inspector slider value? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                