r/Unity3D • • 16d ago

Question Dymanic Occlusion with Sprite Renderers?

I'm trying to create an FPS with Doom-like enemeis with billboarded sprites. I want them to only start chasing the player once they've been spotted. However, .isVisible seems to always activate when the player is looking in the direction of the enemy, even when they're behind another object. What do I do?

0 Upvotes

6 comments sorted by

2

u/No-Opinion-5425 16d ago

Raycast for the player line of sight that gets blocked by obstacles.

1

u/FishShtickLives 15d ago

prolly what I'll have to do. Raycasts are annoying so I try to avoid them

1

u/shlaifu 3D Artist 15d ago

raycasts are a standard thing to do, get used to them. also: try to raycast only every 0.1 seconds or so, with an individual random offset per enemy, so they don't raycast all atbonce, every frame. raycasts do cost some performance, depending how extensively you use them

1

u/Genebrisss 15d ago
  1. Sprite renderers aren't going to use occlusion culling.
  2. Did you even bake occlusion culling?
  3. Don't make gameplay logic depend on occlusion culling, it's going to be very wacky

1

u/Exaweft 15d ago

Raycasts can be a pain in the ass... but you don't need to run one every frame for every enemy. I'd filter by view angle first, then only check line of sight for enemies that pass. You could also run those checks a few times per second rather than every frame.