Submissions from 2017-10-27 to 2017-10-28 (2 total)

Got some pretty primitive line-of-sight going. Initially, I looked into Bresenham's algorithm for this, and I'm sure it could work, but it is only 'valid' for the 1st (of 8) octanes of a traditional 2D coordinate space. To make it work for the other 7, you have convert the coordinate system the points are in, and then convert back. I had the octant-1 solution working, but got headaches trying to implement the coordinate converters (actually more like "trying to figure out what octant a given point is in).

Anyway, then I found a simpler (but probably more expensive) approach on RedBloggGames' blog that relies on linear interpolation, and works in all octants!

The 'World' map now exposes a simple function, HasLOS(p0, p1), that can be used to check if there is a line of sight between the 2 points. This was easily hooked up to my AttackAbility (it will now fail if there is no LOS), and even better, it is used in my fog of war system to determine if the player can actually see a tile that is in range. Behold:


As the player moves around, he explores the map, but everything he can't directly see at the moment goes into fog. His sight is limited to what (1) is in range and (2) he has a LOS to. Neat!

Soooooo, about my lack of math/physics skills. While I still don't claim to have retained too much from my college math and physics courses, it turns out that I can correctly implement formula if they're given to me. What I can't apparently do is actually take the output from the formula and actually apply it correctly to my player.

A fresh mind this morning equated to quickly identifying the problem. The angle I'm calculating is used to rotate around the X-axis. To properly align my weapon, I also need to rotate around Y-axis. I was accomplishing the Y-axis rotation by simply taking advantage of Unity's Transform.LookAt() function to simply 'LookAt' the target. I was 'smart' enough to know I needed to zero out the elevation of the target to match my gun's elevation before rotating along the Y-axis. However, my hazy mind from late last night was taking 'zero out' too literally: I was simply setting the target's Y elevation to 0 instead of to the gun's elevation. As a result, the LookAt() call was rotating around both the Y and X axis. When I then applied my calculated X-axis rotation, I was always coming up short.

In other words, I was doing something stupid. Just goes to show you that sleep is, indeed, important.

With that stupidity out of the way, I updated my pistol and machine gun to use the new ballistic solution calculations. Granted, thanks to their velocity, they still basically shoot exactly how they were shooting before the update. I also threw together a quick prototype grenade launcher. It's much easier to see the ballistics in action when I fire off a few rounds of it.

Oh, and there's now explosive barrels. Because, why not?