Shadow Casters and Line Of Sight

This forum is currently in read-only mode.
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I'm trying to design a game that revolves heavily on the Shadow Caster behavior.

    I'm using tiled backgrounds with the Shadow Caster behavior enabled and it works great, however whenever there is a 'joint' where two of the backgrounds meet, the shadows overlap each other. I know it's happening becayse they're seperate objects but I'm trying to get around that so the shadows look a bit more natural.

    The way that makes most sense to me is instead of having the walls themselves be shadow casters, have the walls bordered on every side with invisible Shadow Casters. Then have any ones the player has Line of Sight to be deactivated or have their Shadow Depth set to 0, both have effectively the same result.

    However, I can't seem to get it to identify the ones with LOS reliably. It'll go for a while and then one will suddenly register as LOS and stop casting a shadow, or I can move around another and it continues to cast shadows.

    I have the LOS setup to only register the shadow casting objects as blocking LOS so nothing else should be in the way.

    I don't know what the best set of commands to test for the LOS. I currently have the following

    -for each 'Shadow Casting Object"

    + "Player" has LOS to "Shadow Casting Object"

    set "Shadow Casting Object" Shadow Depth to 0

    ELSE

    set "Shadow Casting Object" Shadow Depth to 5

    Hopefully I'm just missing something obvious. If not I can post the source file shortly to see if someone can help figure out what I'm doing wrong.

  • I've come up with a solution that I believe works, I just had to approach it from a different angle. (one that would take less processing power to boot, that's always a plus.)

    Dropping the LOS idea entirely, there are now four different types of Shadow Casters. One for each north, south, east and west facing walls. They are very thin and place along the edge of each wall.

    To prevent the Shadow Casters from from casting shadows onto the graphic of the wall, east facing Shadow Casters have their shadow depth set to 0 if the players X value is greater than their own. So on so forth for the other three.

    It works pretty well, there's a few odd looking bits when there's spots where three walls make a sort of T corner, but some creatively placed casters of the appropriate type hidden inside the wall will make it look better when looking from certain directions.

    Hopefully I'll have something to post on the 'Creations' forum with this shortly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Posting a .cap file showing the problem might help. Also, I'm not sure what you're expecting 'ELSE' to do following a for-each event. When should it run? When not for each object? What would that mean?

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