Hi all,
I’m doing a tutorial space shooter but have hit a snag and cannot after 3 hours of searching and recoding and searching recoding and… ARGH!
So here’s the deal. Basic blocks falling down and a block as the player (space invaders set up). I want the falling blocks to destroy themselves if they hit the player and I want the laser that the player fires to destroy the block. So in the tutorial I have ensured I have all of the rigidbody, tags and colliders set up exactly like they do. Then I put this code in, which is exactly what they do (and their’s works). Please… for the love of God tell me where I am going wrong.
When i start my game the falling block dissapears (destroys itself before colliding). This script is running in the enemyscript.
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
Destroy(this.gameObject);
}
if (other.tag == "Laser")
{
Destroy(other.gameObject);
Destroy(this.gameObject);
}
}
One thing, please don’t give me other or better ways to do this. For the moment I just want to get why THIS code is not working. Why it is jumping straight to destroy itself without hitting the OnTriggerEnter part.
Huge thanks in advance.