I have 2 objects in my scene, one that plays an audio clip when i collide with it and another that i want to remove the 1st object when i collide with it.
I can remove the item im colliding with on collision but not the other object.
any help on this ??
I presume you have 2 objects: 1 that plays a sound when get hit and another that removes the first object when it gets hit?
If that is the case then you just need to do something like this (I have not checked the code in unity, so there can be syntax errors)
public class SecondObject: MonoBehaviour
{
public GameObject FirstObject;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider collider)
{
Destroy(FirstObject);
}
}
Add that script to the second object, then drag and drop the first object into the “FirstObject”-field in the inspector and then you are set to go.