I am programming a game that should remove a wall when 12 objects are collected. However, Unity gives me this error message:
Assets/Scripts/RemoveWall.cs(16,17): error CS0029: Cannot implicitly convert type int' to
bool’.
Here is the code and the script that is referred to:
using UnityEngine;
using System.Collections;
public class RemoveWall : MonoBehaviour {
public GameObject removewall1;
public PlayerController playercontroller;
void Start()
{
PlayerController count = GetComponent<PlayerController> ();
}
void Update ()
{
if (playercontroller.count = 12)
{
GameObject removewall1 = GameObject.FindWithTag ("RemoveWall1");
if (removewall1 != null) Destroy(removewall1);
}
}
}
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
public Text countText;
public Text winText;
private Rigidbody rb;
private int countact;
public int count;
void Start ()
{
rb = GetComponent<Rigidbody>();
count = 0;
countact = 0;
SetCountText ();
winText.text = "";
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed);
if (count >= 12)
{
if(count >= 24)
{
if(count >= 36)
{
if(count >= 48)
{
if(count >= 60)
{
if(count >= 72)
{
if(count >= 84)
{
if(count >= 96)
{
if(count >= 108)
{
if(count >= 120)
{
if(count >= 132)
{
if(count >= 144)
{
if(count >= 156)
{
countact = count - 156;
}
countact = count - 144;
}
countact = count - 132;
}
countact = count - 120;
}
countact = count - 108;
}
countact = count - 96;
}
countact = count - 84;
}
countact = count - 72;
}
countact = count - 60;
}
countact = count - 48;
}
countact = count - 36;
}
countact = count - 24;
}
countact = count - 12;
}
else
{
countact = count;
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Pick Up"))
{
other.gameObject.SetActive (false);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = "Count: " + countact.ToString ();
if (count >= 168)
{
winText.text = "You Win!";
}
}
}
I would appreciate any help. Thank you!