score not increasing and staying at 1
im trying to make a game like pipe dream. i have a system where you have a score for where objects are if your score is greater than the max score you change levels. if the thing is a child of a certain tag score goes upwards. however score isnt going upwards and is simply staying at 1 the boolean for if its on the right thing is true so it should add to the score. whats the problem i cant see it.![alt text][1]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class DetectionScript : MonoBehaviour {
public int score;
public bool pointAdded;
public int MaxScore;
public int add;
// Use this for initialization
void Start () {
MaxScore = 9;
score = 1;
pointAdded = false;
add = 1;
}
// Update is called once per frame
void Update()
{
if (transform.parent.tag == "Horiz" && !pointAdded)// if points added = true and its parent is whatever do this
{
score = score ++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "Vert" && !pointAdded) //if points added = true and its parent is vert and it is rotated 90 on its z
{
score = score ++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "TL" && !pointAdded)//its parent is tl
{
score = score ++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "TR" && !pointAdded)//its parent is tr
{
score = score ++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "BL" && !pointAdded)// its parent is bl
{
score = score++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "BR" && !pointAdded)// its parent is br
{
score = score++;
pointAdded = true;
Debug.Log(score + " this sucks" + pointAdded);
}
if (transform.parent.tag == "Blank") // copy and paste this on the thing you dont want to give points if blank no points
{
score = 0;
pointAdded = false;
Debug.Log(score + " this sucks" + pointAdded);
}
if (score >= MaxScore)
{
SceneManager.LoadScene("basics scene should be good");
}
}
}
`
can you debug.log the pointadded value? also make sure all tags are right spelled since its a common mistake not having caps etc
the debug.log shows points added value as true meaning that they are in the right place so i dont know what the problem is
Thats the problem is obly entering the if statement if its false since you are using a !
i removed the hashtag and what happens is that the debug.log keeps continually logging for each second and the score doesn't go upwards.