Announcement

Collapse
No announcement yet.

Is it possible to tell if a character is standing in a shadow (is shadowed)?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is it possible to tell if a character is standing in a shadow (is shadowed)?

    Hello! .(^_^)/

    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?

    Thank you for your help!
    Last edited by spacegojira; 11-25-2017, 04:44 AM.

    #2
    Hey, I'mma give you my 2 cents.

    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.

    Comment


      #3
      Originally posted by EU_Coxis View Post
      Hey, I'mma give you my 2 cents.

      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.

      Oh yes, I forgot to mention I am using dynamic shadows, that's why I can't use a collision box. I will update my original post.

      Comment


        #4
        Actually, now that I think of it, you can cast rays from your sun position, to the ground. And whatever those rays hit, gets "heated".

        if your character would be standing in a room, would not be hit by those rays, so it would be "cooler".

        Comment


          #5
          Originally posted by EU_Coxis View Post
          Actually, now that I think of it, you can cast rays from your sun position, to the ground. And whatever those rays hit, gets "heated".

          if your character would be standing in a room, would not be hit by those rays, so it would be "cooler".

          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.

          Comment


            #6
            Hey, glad that helped!

            Comment


              #7
              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?

              Comment


                #8
                Originally posted by Anadin View Post
                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?
                Yeah I was thinking about how to do being partially lit by the sun, and that's a good idea.

                Comment


                  #9
                  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.

                  Comment


                    #10
                    Originally posted by WixZ View Post
                    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.
                    Yes, that is exactly what EU_Coxis suggested and what we have been talking about in the last posts. :P

                    Comment


                      #11
                      Originally posted by spacegojira View Post

                      Yes, that is exactly what EU_Coxis suggested and what we have been talking about in the last posts. :P
                      Oh, sorry I didn't read through the thread. Just wanted to drop my idea just in case it could be helpful.

                      Comment


                        #12
                        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.
                        Last edited by EU_Coxis; 11-27-2017, 04:23 AM.

                        Comment


                          #13
                          Originally posted by WixZ View Post

                          Oh, sorry I didn't read through the thread. Just wanted to drop my idea just in case it could be helpful.
                          I know, I was just a bit sarcastic. Thank you for your feedback.


                          Originally posted by EU_Coxis View Post
                          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.
                          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.

                          Comment


                            #14
                            Originally posted by WixZ View Post
                            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.
                            The raycast idea is a good one and quite efficient.
                            Check out my itch.io page, I'm really excited about it.
                            https://kinos141.itch.io/

                            Please check out my AI package: Action AI System Feat. Stealth
                            https://www.unrealengine.com/marketp...m-feat-stealth
                            or get it from itch
                            https://kinos141.itch.io/action-ai-system-feat-stealth

                            Comment

                            Working...
                            X