0 Favourites

How do I Flashlight view

  • Hi everyone!

    I wanna create a flashlight view similar to "fog war", something like:

    • an object "shadows" in the layer's top whitch is black with 60% opacity (aprox)
    • enemies out the flashlight view are hiden
    • scenary is allways visible but when the flashlight is off is all in shadows, (because the top object "shadows"), but when you focus your flashlight the shadows disappears in the cone of view and you can see the true colors of the objects and background and the enemies become visible.

    I can't find any tutorial about this lighting effect, so please if you know about one, link it to me, or if you did something similar please advice me about how to do it.

    thanks for your time

    regards!!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Here's one I made a while ago, but if you adjust the shape of the Torch to suit the shape you want, it should work well.

    Main things is you need to have 2 layers, 1 which is the FOW and the other which is below it. The FOW layer must force its own textures (Under layer properties). Also you need to set the fade to a fairly low time, or it will just remain on screen, and to use the blend mode Destination Out.

  • here is a slightly adapted capx from https://www.scirra.com/tutorials/793/the-land-of-light-and-shadows-part-2 (sad self promotion )

  • Thanks, i'm going to response in this thread the results of my work

  • Hello everybody, I come back with more questions!

    Thanks to your help I could do something similar to a Flashlight view, but between some bugs that need to be fixed I have one for what I need your help.

    Do you see the superior wall call "muro_exterior"? the function "fisica linterna" can't calculate the distance between the flashlight and it.

    I think that it is because this sprite is an instace with modificated proportions of the original object, but I'm not sure of that.

    Any idea?

    Thanks!

    src: h t t p s ://mega.co.nz/#!JtQH1IZI!MOSpHb6kCThOf4k4JzArUXIg2MbA9-XxSefZam67Pek

  • you are saying

    if the flash light is touching the wall set the length of the flash light to the distance from the (location of) flash light to the (location of) wall

    but

    the wall is very long and its (the wall) location is not where the flash light is touching ie the wall might be 400 pixels long and 30 pixels high with its location (centre) at 200 pixels from it left hand side - so if the flash light touches the left hand side of the wall then its length will be set to 200 plus pixels . Does that make sense ?

    One way around this would be to use much shorter lengths of wall to make your exterior wall.

    Thanks for doing the tutorial translation.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)