Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enemies sometimes hearing thru walls #2681

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

petchema
Copy link
Collaborator

@petchema petchema commented Aug 3, 2024

Previous code checked that the first obstacle between an enemy and its target was an object tagged "static" to determine if the enemy could hear the target (followed by a distance check).
In some cases that allowed enemies to hear targets when they shouldn't (other static tagged objects along the "line of hearing" not checked), leading to enemies facing walls or still chasing enemies thru walls when you encounter them.

This PR first checks for distance to target (like CanSeeTarget() does), then checks if they're no object tagged static inbetween the enemy and its target.
As an optimization, only objects on layer "Default" are considered, and Physics.RaycastNonAlloc() API is used to lower memory allocations.

Forums: https://forums.dfworkshop.net/viewtopic.php?t=6759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant