[Solved] EnemyBehavior not recognizing functions in Projectile script

I wrote my EnemyBehavior and Projectile scripts, and I did them exactly as was shown in the lecture, but when I played the game, the lasers were just passing through the enemies and not causing damage. I even tried adding a Debug.Log to my Projectile script, and sure enough, no console logs. So what am I missing here? Why are the scripts not linking up, or why is the trigger not getting registered?




Thank you for your help!

2 Likes

Hello, is there any chance that they are not colliding at all, because of layer settings?

1 Like

Please show an inspector screen shot of the laser please.

1 Like

Hi @hypnometal

Your problem is that you are checking for the projectile on the enemy game object instead of the projectile that just collided with you.

So replace line 20 with

Projectile missile = coll.gameobject.GetComponent<Projectile>();

2 Likes

Yes, that was it! Thank you! :slight_smile:

2 Likes

You are welcome @hypnometal

1 Like