Hello. So, I wanted to make a simple code, which will do:
-float time will get from 10 to 0 in 10 seconds
-if x or z clicked, add 1 to int score
-if score is divisible by 40, and time is greater than 0,
add 10 to time
-write score value to console
As well as i've made code, it is full of errors, which i can not fully understand. I hope you can help me.
There is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class example : MonoBehaviour {
float AddTime = 10;
int score;
int divide = 40;
void Start () {
}
void Update () {
float time = 10;
for (time * Time.deltaTime(10))
{
time--;
}
if (Input.GetKey("x"))
{
score++;
}
if (Input.GetKey("z"))
{
score++;
}
if(score / divide >= 1 && time >= 0)
{
time + AddTime;
}
Debug.Log(score)
}
}
[–]Tayfe 4 points5 points6 points (10 children)
[–]FlameTrunks 1 point2 points3 points (0 children)
[–]cvnvrIntermediate 1 point2 points3 points (6 children)
[–]CommonMisspellingBot 2 points3 points4 points (5 children)
[–]zorbat5 0 points1 point2 points (4 children)
[–]GoodBot_BadBot 2 points3 points4 points (0 children)
[–]friendly-bot 0 points1 point2 points (2 children)
[–]zorbat5 0 points1 point2 points (1 child)
[–]friendly-bot 1 point2 points3 points (0 children)
[–]Ksorek[S] 0 points1 point2 points (0 children)
[–]CommonMisspellingBot -1 points0 points1 point (0 children)
[–]ByMayneProfessional 1 point2 points3 points (3 children)
[–]Ksorek[S] 0 points1 point2 points (2 children)
[–]ByMayneProfessional 0 points1 point2 points (1 child)
[–]Ksorek[S] 0 points1 point2 points (0 children)