Shadow Casters and Line Of Sight

For questions about using Classic.

Post » Thu Jul 09, 2009 1:35 am

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.
B
5
G
3
Posts: 23
Reputation: 975

Post » Thu Jul 09, 2009 5:55 am

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.
B
5
G
3
Posts: 23
Reputation: 975

Post » Thu Jul 09, 2009 10:01 pm

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?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests