mission-demolition/Assets/Scripts/Goal.cs

23 lines
694 B
C#
Raw Normal View History

2024-02-19 20:49:09 -06:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goal : MonoBehaviour
{
// A static field accessible by code anywhere
static public bool goalMet = false;
void OnTriggerEnter(Collider other) {
// When the trigger is hit by something
// Check to see if it's a Projectile
if (other.gameObject.tag == "Projectile") {
// If so, set goalMet to true
Goal.goalMet = true;
// Also set the alpha of the color to higher opacity
Material mat = GetComponent<Renderer>().material;
Color c = mat.color;
c.a = 1;
mat.color = c;
}
}
}