I would like to ask if it’s possible to tell, via blueprints, if the player character is standing inside a shadowed area?
The thing is I am building a game with temperature (in a desert), so I would like the temperature to slightly drop once the character is walking into a large shadowed area. Just like in real life, where you would cool down by getting out of the sun.
However I am using dynamic lighting only (day night cycle), because of this I can’t use a collision box or similiar static workarounds for the shadowed areas.
Is this possible and if so, how could I achieve this via blueprints?
If you have just static shadows, you should be able to do that with a blueprint with a collision box. And just place your fields wherever the shadows are.
But if you have some dynamic shadows, i.e. sun changes position over time and therefore, your shadows move with it, it will get complicated, as you’ll need to calculate that in your blueprints.
Other than that, I’m not aware of a way to get that data from the rendering engine. But as I’m relatively new to UE, there might be a way that I don’t know of.
Oh that’s a great idea! But wouldn’t it cost me thousands of rays then to cast over the whole area? Hmm unless I calculate the direction from the sun position to the characters position and only use one ray.
Thank you for the tip, I will try to build a blueprint for that now.
perhaps do a ray from the top (or middle of your mesh) AND the bottom. the two rays will at least then let you know that you character is at least 50% shadowed?
You can also use a raycast that goes from the sun to your character, when the raycast hits something it means your characters is behind an object aka inside a shadowed zone. I’m not sure how accurate you want this to be though, but if you want more accuracy than just the middle or head of the character’s shadow detection you can also have multiple raycasts, like one for feet, one for middle and one for head and check if any of those are ever blocked which will give a more accurate detection.
Btw, comming up with another suggestion if you haven’t done it already.
While calculating your temperature, you could also take in account where the sun is on the sky, since while being at sunrise or sunset, the sun’s radiation would heat up objects less than while being up at noon, because the radiation waves are tangent to the planet’s surface so they scatter more in the atmosphere than they do when perpendicular.
I think this would be a nice touch to your game.
Edit: Aaaand, if you got wind going on, wind cools down things. So you can get that into account as well. But maybe this gets too complicated for what you actually want. I have no idea, but hope it helps.
I know, I was just a bit sarcastic. Thank you for your feedback.
Ah yes, I am using a time system to determine where the suns locations is. And then I will use certain time zones (like 18:00 - 20:00) to set a temperature.
Probably I will make it that at 20:00 there is a certain base temperature, and from 18:00 it starts going towards that.
I want to use wind later on (I am still in prototyping phase), but I have to see if it get’s too complicated indeed. Although it would be really interesting.