RaycastFor Enemy Error:RE

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.

I solved it by raycasting for the Enemy layer instead of the component, like in the case of PotentiallyWalkable.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms