GMS 2.3+ Problem with GMWolfs lighting system

Palocles

Member
@GMWolf

I used your system from the youtube video of 2017 and included the correction you linked in this forum and it mostly works except that the dark area is not the same size as my camera view and, probably because of the reduced size, the sprites/light areas do not stay fixed relative to the BG.

See comparison below:
DarknessLayerProblem.png

If I can sort that out I also want to know how to get one of the light source sprites to follow another object.

Thanks so much for your help.
 

GMWolf

aka fel666
I used your system from the youtube video of 2017 and included the correction you linked in this forum and it mostly works except that the dark area is not the same size as my camera
Make sure you create the surfaces the same size as the camera.


the sprites/light areas do not stay fixed relative to the BG.
Something in GM changed and brings the way I reset the view using surfaces.
I outline a good here https://forum.yoyogames.com/index.php?threads/solved-surface-moves-with-camera.53382/post-32563


If I can sort that out I also want to know how to get one of the light source sprites to follow another object.
The point of this technique is to be able to use any layer as a light layer.
So instead of using an asset layer for your lights, you can use an instance layer. Then you can easily make one of those instances follow the player.

With a bit of work it's even possible to have multiple layers.
 

Palocles

Member
Thanks for your reply.

I just made my light surface bigger and it seems to have fixed the darkness area and movement problem*. I guess the camera view I am using is bigger than I remembered. I wanted to size it to the camera view size automatically but don't know which function to use.

*I checked it again and there is very slight movement of the darkness relative to the background, not noticeable in a small area but will definitely be out of alignment after a screen width of movement. So I will have to sort that out still**.

**I found the view size in my room properties and matched it and it's working correctly now.

I'll read through your other post and try make that work but I'm not terribly proficient with GMS; basically taking the code that works for me from YouTube tutorials and combining them like Frankenstein's monster.

It is pretty important to my game concept that I can have a dark level and a light area will surround and follow the player and some of the enemies/projectiles. I guess I can use some code something like this for it:

in object create step:
if(roomDark == true)
{
create an instance of sprLightSource at this objects position
set the layer of the sprLightSource to the light layer
}

and in the step event:
if(this object is mobile)
{
code to match light source position to mobile object position
}

If I can figure out how to do this for the player I can transfer it to the mobs.
 
Top