I am trying to change the color of a gameobject based on the number of collisions it is in.
With this code, I get the error message: cannot implicitly convert type ‘int’ to ‘bool’
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChangeColorOnCollision : MonoBehaviour
{
int counter = 0;
void OnCollisionEnter(Collision col)
{
counter ++;
}
void Update()
{
if (counter = 1)
{
transform.GetComponent<Renderer>().material.color = Color.blue;
}
if (counter = 2)
{
transform.GetComponent<Renderer>().material.color = Color.red;
}
}
}