21 Oct 2019 - vidya
Off to a good start! The basic combat functionality has been implemented.
The idea is inspired by games like Enter the Gungeon, albeit with a minor twist. I wanted the player to be able to attack in a full 360 degrees (which works a little differently in 2.5D space!).
Essentially, a Ray is shot from the camera and the point of intersection between the Ray and the Ground is recorded. I then use that position to calculate a “vector angle” (for example, “1,0 = right” or “0,1 = up”) from the player’s position towards that point of intersection. The player’s hands exist in a parent object that rotates to face in the direction of that angle. This allows me to reuse the same sprites for attacks in any angle.
It took some noodling with the sprite alignments and Z-sorting, and some of that stuff is still being tweaked as you can see:
I don’t really expect I’ll put the very precise level of polish required to clean up some the sprite sorting in very soon. For now, the functionality is my focus!
After calculating the rotation of the hands’ parent object, that vector angle has its magnitude clamped based on the range of the player’s attack (a punch shouldn’t reach as far as a gun, of course), and a new point on the Ground is calculated. Right now, I simply instantiate a collision event at that point and see what enemies are inside. My goal is to later include targeting for various target types, including the tiles on the ground!