Hey all,
Working on a stealth game where you play as a vampire avoiding the sun. You can move the shadows by moving the lightsource.
I use the shadowcast behavior to show shadows visually, but I have a function that handles if the player is overlapping the shadow (since you can't check that collision).
The function works great except for a recent development causing issues. I've tried rewriting the function a few times but no dice. Would love some feedback on how I can make this work better.
It's a weird system, so I'll attach the function screenshot, explain how it's used and then a picture i drew explaining it.
This is the function. It takes a pointX and Y and returns whether that point is in shadow (0 is not in shadow, 1 is in shadow)
I call the function on all ticks on 4 image points of the player. If all 4 image points return false, I assume the player is exposed to the sun and deal damage.
Here's a drawing showing the problem.
The system works great normally. But I've started adding other obstacles that are solid objects which are interfering with the raycasts.
The weird thing is that I've had fences (solid, 9-patch) and they don't cause the same issue. Not sure why that is.
Here's a gif showing the problem in action.
media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExOGM4emh1cTY3bzY0MW93eHY1cDQwN3dkZ3Y1cTlvdGFkaDR5a3NtMCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/X6K1SqO0z2kBSHHkoM/giphy.gif
Any help or ideas would be much appreciated. Seems like a simple problem but for some reason I'm stumped. If only I could just only consider raycast collisions on shadowCaster objects.
Thanks!