Hello,
I’m new to programming so i’m having trouble with a script.
I can’t get my player activate a script that is on himself when he arrives in a trigger zone.
i just want that, when my player arrives in a trigger area, a script that is on my player activates and work when i’m on the area, and when i’m not on that particular area stop. The script is a script that activate a shader (the script with the shader is working when i’m just putting it on my player).
Thank you.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class trigger : MonoBehaviour
{
void OnTriggerEnter(Collision other)
{
if (other.gameObject.tag == "Player")
{
Script Chunky = other.gameObject.GetComponent<Chunky>();
Chunky.enabled = true;
}
}
void OnTriggerExit(Collision other)
{
if (other.gameObject.tag == "Player")
{
Script Chunky = other.gameObject.GetComponent<Chunky>();
Chunky.enabled = false;
}
}
}