How Can I Make An InUnity3DGame Variable (Integer) [Help]
I want to make a variable that will work In The Game . I mean I tryed this :
and it didn't work . I don't know why . There were not any errors .
The project I want to do is ... When I have 5 points to have the permission to close or open the lights , if not then I have to gather points pushing button "O" . Can anyone help me ?
Code:
public class flashing : MonoBehaviour {
// Update is called once per frame
void Update()
{
int points = 0;
if(Input.GetKeyDown(KeyCode.O)){
points += 1;
}
if (Input.GetKeyDown(KeyCode.F))
{
if(light.enabled == true && points == 5){
light.enabled = false;
points -= 5;
}
else if(light.enabled == false && points == 5){
light.enabled = true;
points -= 5;
}
}
}
}
The project I want to do is ... When I have 5 points to have the permission to close or open the lights , if not then I have to gather points pushing button "O" . Can anyone help me ?