My EnemySpawner enemies don't shoot

Hi, I’ve been following the course, awesome stuff!

My problem is that the enemies spawned that go through the waves don’t shoot, it’s only the one Roger I dragged into my scene that shoots.

I’ve rewatched this section a bunch of times, and I’m doing everything logically as presented, just stuck on this issue.

Any help would be very much appreciated.

Thanks! <3

I know this is an old post I’m replying to, but maybe my reply will be helpful to others. I had the same issue described by Cdnalsi and discovered that my enemy lasers were immediately colliding with the enemy’s rigid body 2D component. Due to the interplay between the Enemy script and the DamageDealer script this means that the laser is immediately destroyed. Another factor, or so I suspect, is that my wave config patterns are primarily downward motion (this may be why Cdnalsi’s non-moving Roger shot lasers just fine).

My solution was to instantiate the laser just a bit lower than the enemy, thus getting it outside of the collider.

    private void Fire() {
        var laserTransform = transform.position;
        laserTransform.y -= 1;
        var enemyLaser = Instantiate(projectilePrefab, laserTransform, Quaternion.identity);
        enemyLaser.GetComponent<Rigidbody2D>().velocity = new Vector2(0, -projectileSpeed);
        projectiles.Add(enemyLaser);
    }

At some point, I might create a solution whereby an enemy projectile doesn’t interact with an enemy.

Privacy & Terms