Question by
Camilla_C · Dec 03, 2017 at 11:55 AM ·
textontriggerenterboolgetbuttondowntostring
How to stop score adding after a OnTriggerEnter
When the jump is pressed score is added on to text by one, but when I die if I continue to press jump, the score keeps adding on. How do I stop this? I understand that I might need to use bool, but not to sure how to. This is what I'm using to add score.
public Transform player;
public Text scoreText;
public int score = 0;
// Update is called once per frame
void Update ()
{
if (Input.GetButtonDown("Jump"))
{
score++; //everytime jump is active it increments the score by 1
scoreText.text = (score).ToString(); // sets the text to display the current score
}
}
Comment
Answer by buryo95 · Dec 03, 2017 at 12:35 PM
Hey @Camilla_C, you need to add your code into the Code sample which you can use by the shortcode CTRL + K or press the button above the textfield look at the image : https://gyazo.com/83b67a39540646cdff517a0b9e7e9460
Its not readable like this
Your answer
Follow this Question
Related Questions
Stopwatch will not show time. 1 Answer
Calculation with values over 2 billion 1 Answer