22

Hopefully the title is self-explanatory but some more details:

  • game is in isometric perspective with the camera locked to the player but from a significant distance away, creating high likelihood of obstructions by the level and decorations occuring
  • I want the player to see their character's vision and not have these obstructions block the player's view.

One way to achieve this might be to use raycasts from the character to hide objects (like walls or buildings) if they collide with an object on the opposite side to the camera. A slight problem there is if buildings have interiors then the rays wouldn't necessarily hit all relevant objects. Sometimes both the interior and exterior of the building would need to visible.

I've seen a few videos on stencil buffers but my understanding is that this might not apply, but I will admit to not understanding them well. Any help appreciated for this newbie to game dev.

top 3 comments
sorted by: hot top new old

A hint i found on Reddit (yikes, i know) from someone who made a nice github with their solution.

Their idea is to pass the player position to the objects shaders, and then to get 2 differents normals : from object to player, and from object to camera. Once you have those, you can make a dot product to tell if they are in the same direction or not (>0.0 if their angle is less than 90°, <0.0 if it's greater, 0.0 would correspond to a 90° angle). Beware, i believe it's best to normalize both your vector to a length of 1, before using dot product if you want to get accurate results.

So once you have a negative dot product, you know both direction are opposite, so the object is between the camera and the player, and should be hidden.

On top of that, they limit that effect to a small circle around the player, to avoid making objects transparent all over the screen. You'd have to find out how to limit that effect to the field of view of the player, and i sadly have no real idea about that.

The player's view is just another normal. If you set an angle range for how large their field of view is, and then check that the player's normal and the vector from object to player are parallel enough, it shouldn't be too hard.

Oh, yes quite smart and maybe also computing the distance between the player and the object, to avoid making transparent objects that are in player's sight but very far away

this post was submitted on 09 May 2026
22 points (100.0% liked)

Godot

7635 readers
10 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 3 years ago
MODERATORS