Adding line of sight


Onikai uses "line of sight" to determine which units are reachable by the other team. 


This means that units can be "blocked" by their teammates from being hit. Strategically this means that you can place a big unit with a lot of armor, in front of a weaker one to protect them. So how do we implement that?



Well it's pretty simple, we give each unit a box which is as large as it's own tile, then we shoot rays at potential targets and only returns the ones that hit.  


it's important to note that the collides are the size of the square the units occupy, and they are all the same size.  This makes it so that no rays squeeze in between at odd angles



Notice we cannot "see" the units in the back, as noted by the 🚫

Once a unit is dazed, we make its collider really short (so that they can still be targeted, but cannot block line of sight), and presto, everything just works.


Now to finish the job 😈 🏹🏹🏹



Play Onikai for free, in your browser, right now!
http://mythicalelephantgames.itch.io/

Leave a comment

Log in with itch.io to leave a comment.