im making top down game , now i have player and enemy can follow player ,
but i wrote script to make enemy destroy player if he touch him ,and its not working (there is one error in ontiggerenter2d
and nothing is working)
i tried it without ontiggerenter2d in update and still dont working
using UnityEngine;
using System;
public class colliderscript : MonoBehaviour
{
public GameObject square;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
OnTriggerEnter2D();
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "player")
{
Destroy (square);
}
}
}