Had the exact same error as described here: RaycastForEnemy Error
However instead of replacing all of my enemies, I tried deleting a few GameObjects off the screen at a time, and discovered that removing the AudioTrigger
script from the enemy appears to work fine. Perhaps a quirk of raycasting with the spawned SphereCollider
on the AudioTrigger prefab? Exactly as described here by Tuirennder: Consider using layer masks instead of relying on GetComponent.