Hi guys!
Been puzzled by this for the last 4 hours. In a nutshell, I only want my Particle PreFab to run while my “Player” tag is in the trigger zone. Right now, I can instantiate the Prefab “Visual” when “Player” enters the trigger zone however its trying to stop the prefab when the “player” leaves that I’m finding difficult. My current code obviously gives me “Destroying assets is not permitted”
As I’m still a bit new i’m having trouble accessing the myPart Prefab (Clone) to delete upon my “Player”'s exit trigger.
Any help is much appreciated.
`public GameObject visual;
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
GameObject myPart = (GameObject)Instantiate (visual);
}
}
void OnTriggerExit(Collider col){
if (col.gameObject.tag == "Player") {
Destroy(visual);
}
}`