I am trying to create an endless runner where i have ghost-like enemies, which die from bullets, but the player can go through them if they are not dead. The problem is, I can't make it so the player can go through the enemy. I have tried making a script and attacking it to the enemy, but it does not work and the enemy stops the player. Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyController : MonoBehaviour {
public GameObject Enemy;
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.name == "Player")
{
Enemy.SetActive(false);
}
}
}
Any help
↧