Hello everyone,
I have a problem with a trigger.
Basicaly I want the the trigger to work only when the player pass on it.
But if an enemy collide with it or a bullet collide with it, it gets activated.
I tried to put a tag on the player but it doesn’t seems to work because the trigger doesn’t recognize the player or the bullet shooted from his gun.
Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartTrigger : MonoBehaviour
{
public GameObject Player;
public GameObject Spawns;
public GameObject Trigger;
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Player"))
{
Spawns.SetActive(true);
}
}
void OnTriggerExit2D(Collider2D other)
{
Trigger.SetActive(false);
}