So, i wanted to make a character be able to detect shadows so it can use a mechanic.
one problem i dont know how to…
i’ve seen one post about this but it never went to depth about it for me, who’s still a bit too green when it comes to coding, to understand it.
any advice or links for this problem?
1 Like
You could do a line trace from the character to the light. If it hits, you’re not in shadow.
It’s probably a bit more complex than that, but the basic idea is ok
( example is coming, having a technical issue… )
1 Like
Ok, this
As you can see, I get a ray ‘coming from the sun’
When the ray hits my cube, it’s ok, when it doesn’t, the cube turns pink
Lot of caveats here
- This code assumes you’re using the standard lighting setup.
- By default, the player won’t block traces ( why I used the cube ), but you could change the player collision, or add extra components etc
- It only works if the sun is hitting/not hitting the head, in this case.
- Important
2 Likes
ohhh okay, this makes a lot more sense.
thanks a lot, this gives me a better understand on how exactly I can get this mechanic to work to where its fun for players now
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.