Light obstacle and sprite color

I am new to this, so I apologize in advance if this is a simple fix or just not even possible. I also did not see this answered on any other post.

Problem:

I am trying to make a top down game where darkness used often.

I create a lighting layer, and make everything dark via changing the ambient light.

I create a light and attach it to the player, to move along with it.

When I use the behavior “Light obstacle behavior” on and object (ex: a pillar or wall) the object now casts a shadow. great!

However, that said object is now completely black. Meaning, when the light is cast on it, the shadow appears, but the objects texture is not revealed with the light, it just looks black.

Ex: the red wall now cast a shadow when light hits, but the wall no longer looks red. its black.

From messing around with it, it seems that the shadows work with the objects collision, so shrinking the collision of the object will allow some of the texture to be revealed again, but the shadows then look very unrealistic.

Question:

is there a way to make it so that the light will show the colors AND cast a shadow?

I have attached a picture to show the things I have mentioned.

thank you in advance for any replies.

I’m somehow unable to upload a screenshot at the time, but open the lights example and compare it with yours.
A problem of layer order, I presume.

2 Likes

I found a work around stemming from your suggestion of layer order.

so, Thank you!

For anyone who has a similar issue, here is what I did. It may not be the most practical solution, but it works.

My solution:

-assuming you have already created a player, walls, and light that follows you - try the following

  • I put the walls and columns that I wanted to cast shadows and keep their textures, on a layer above the base. (for example: my walls are on the lighting layer, everything else is base)
  • Create a new sprite that is completely black (or what ever color you want).
  • Make a white circle in the middle with a bit of opacity (so it fades on the edges)
    -Use an event to have this black sprite positioned on your player and follow it around (add action: change position of “black sprite” to “players” X and Y)
    -be sure to edit the point on the black sprite, so that the center is in the middle of the hole.
    -make sure the “black sprite” is on the same layer as your player, not the walls.

I hope this isn’t too confusing.



1 Like