Hey
I don’t know how to make a reference in code to an object I created. For example, the object is named “enemy”
and I’d like to object Sword destroy only this.
This is a code of a Sword class:
using UnityEngine;
using System.Collections;
public class Sword : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other)
{
Destroy (other.gameObject);
}
}
For now, this code deletes all objects in the same Layer…
Please, help me!