Projectile Instantly Self Destructs when instantiated

When I got to the Arrow Projectile part of the Unity 2D RPG: Complete Combat System course the first code used to collide with the enemies (around 3 minutes into that video and provided below) did not work for me in the way it did in the course. It caused my projectile to self destruct on instantiation. I was temporarily stuck but I went through to the next part of the video where the code is extended to include the indestructible class. This seemed to fix the issue. I just wanted to let anyone else that has gotten stuck in the same part know that it may be fixed by continuing the video.

private void OnTriggerEnter2D(Collider2D other){

    EnemyHealth enemyHealth = other.gameObject.GetComponent<EnemyHealth>();


    Instantiate(particleOnHitPrefabVFX, transform.position, transform.rotation);




Privacy & Terms