Hello everyone,
I’m trying to get an object that moves forward automatically to destroy cubes when it collides with them using the OnCollisionEnter method. Here’s my code:
using UnityEngine;
using System.Collections;
public class Destroyer02 : MonoBehaviour {
public AudioClip myClip;
public GameObject otherObj;
// Update is called once per frame
void OnCollisionEnter (Collision collider){
if(otherObj.collider.tag == "Bulls")
{
Destroy(otherObj.gameObject);
AudioSource.PlayClipAtPoint(myClip, transform.position);
}
}
}
RandomUsername this is the code I edited based on your suggestion and I still have the same problem. The object just goes right through the cubes.