Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(3 edits) (+1)

Thank you for your feedback! I'll explain to you the technical side of the shadows (considering you know Unity) :

  • First, I check for every platform in the light (not just the transform.position but every collider.points because if maybe just one part of the platform is in the light, it still needs to show that parts shadow)
  • Then, for each platform, I get all the collider.points from the Collider component of the platform
  • I then create an List of Vector2 directions for each point of every platform in the light. The direction is point.position - light.position. Here is a drawing for your understanding: 

  • After, I multiply the collider.points with their corresponding direction and the light.length (collider.points[i] * direction[i] * light.length). This gets me another sets of points further down the line. Here's a drawing :


And it works with platforms anywhere:

  • Now I have a set of 8 points per platform in the light. The only thing left, is putting the points in a PolygonCollider2D. But theres a problem... Some of these points, are not wanted in the PolygonCollider2D, we only want the exetrior points, and not the inner ones. Because with these unwanted points the collider would be ineeficient and sometimes wouldn't work. But those points change depending on where you put the platform (do some sketches and you'll see that isn't always the two lower ones as we see in this sketch, it depends, really, trust me ;) ) :


  • To find those points I used a ConvexHull Algorithm or a Gift Wrapping Algorithm to find them... You can check out the video below for further details. It basically just to find the outer points of a set of points, like gift wrapping. 
  • After using the algorithm on the points, I put them in a PolygonCollider2D
  • I then have a script, that converts the PollygonCollider2D points of a GameObject into a mesh using the mesh.vertices and mesh.points, etc.
  • If I want the shadow to be solid I keep the PolygonCollider2D active, if not I disabled it.

Hope this helps you understand how the shadows work. I was really proud of what I manage to do, so I was very happy when you asked your question! Thank you! :)

Amazing work :O 

I use Unity, so thanks a lor for the in depth infos. It's going to be usefull in the future! 

Again, Great Job!