DAY #011

#DAY011

Destroying the targets with a bullet.

(using also the script from day 10)

Main points covered

#onTriggerEnter

#Collider

 

C# script (attached to the bullet)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class destroy : MonoBehaviour {

void OnTriggerEnter(Collider other) {
Destroy(other.gameObject);
}
}

 

*OBS: One of the gameobjects must have a Rigidbody and the target must have the is trigger checked.

Leave a Reply

Your email address will not be published. Required fields are marked *