How to i change an object opaciity? im trying to make a wall that changes its opacity based on how much hp it has left. my code is as follows:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Break : MonoBehaviour
{
public GameObject wall;
public float hp = 10f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (hp == 0)
{
wall.gameObject.SetActive(false);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "break")
{
hp--;
}
}
}
i belive the update block is what needs to change, but im not sure.