Vision cone like in darkwood (SOLVED)

Around 2 years ago I posted with the same question. My solution for that time was to use the lighting system. But now that I have another project in mind, I was wondering if anybody has an idea how to make the exact same effect like in darkwood? So the enemies don’t render when outside of field of view, and you can still see the map.

Original post: [SOLVED] Is it possible to recreate the "field of view" effect, like in Darkwood's?

I’m not sure how this is different than your previous post. If you want a visible map or UI then can’t those objects be put on a layer that is higher than the light layer? Is the problem with using lights or showing the map? Or do you want a map that only shows the illuminated objects?

Sorry for making my question unclear. By map I meant the environment itself.

Although I guess messing with the layers could be the answer

Use a combination of the lighting system and a cone shaped sprite that’s the same size and shape as the light. Then either hide the enemy until they collide with the cone sprite, or use the cone sprite as a sprite mask on the enemies.

If you want the enemies to be hidden if they’re not in ‘contact’ with a light beam, then use raytracing to check if they’re within range and line of sight.

I’ve done this in a prototype I made in the past using light objects and the sprite masking extension. Note, the actual extension for the sprite masking needs to be modified to allow the use of “all objects” rather than just sprites. You then add the sprite masking behavior to the light, and use events to hide what you want when not in contact with the light. screenshot attached. You can see the two characters in the bottom right are fully visable, and half visable with other outside of the torchlight not visible at all. Hope this helps.

1 Like

yeah, thanks a lot! Sorry for the very late response