EntroPi-Games / GPU-Line-of-Sight

GPU Line of Sight / Field of View visualization for Unity
Apache License 2.0
129 stars 24 forks source link

problem with seeing gameobjects outside of fov #2

Closed pulpxi closed 3 years ago

EntroPiGames commented 3 years ago

Are you talking about the npc character just outside the line of sight?

What kind of mesh is used to draw the sprite? The mesh might be intersecting the LOS source camera's frustum, while the texture only covers a part of the mesh.

EntroPiGames commented 3 years ago

A Sprite Renderer component will also use a mesh internally to draw the sprite to the screen.

If you set the Scene view draw mode to Shaded Wireframe you should be able to see the mesh that's being used to draw the NPC sprite.

image

EntroPiGames commented 3 years ago

The LOS Culler component uses the mesh's Axis Aligned Bounding Box (AABB) to calculate the visibility of the mesh.

Because the mesh generated from the sprite has some artifacts, the AABB is larger than the sprite itself and does intersect with the line of sight:

image

The best fix would be to clean up the sprite image, so that the generated mesh is cleaner and fits the sprite perfectly.

EntroPiGames commented 3 years ago

My guess is that the NPC sprite contains a couple of pixels which aren't completely transparent, so you might need to fix that in an image editor.

You could also try setting the Mesh Type for the texture to Full Rect instead of Tight.

But the topic of sprite mesh generation is no longer related to this asset, so might be better to ask on the Unity forum instead.