I have this scrip attatched to an object to delete other moving objects using
System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class objectdestroyer : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
Destroy(other.gameObject);
}
}
but I need there to be a specific object that it dose not destroy ( a village)
how do I manage that?
Hello @chris102209 ,
You can do that by adding tags. Make the tags of the gameobjects you want to destroy “destroy”.
The script would be like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class objectdestroyer : MonoBehaviour {
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "destroy")
{
Destroy (other.gameObject);
}
}
}
I hope this helps