49 minutes ago, faatal said:
Health < 50% run away. Cool, but to where? Taking cover is going to be one of the hardest parts of bandits, since what is cover in an arbitrary voxel world?
The best way IMO is to cast a "ray tracing" (was that the name?) from spaces (air blocks) near the bandit, up to the player, and if there's a "free" block nearby that has a collision in the direction of the player that is cover. (did I say this right??)
(player) (cover 1) (bandit) (cover 2)
In this case, both free blocks are cover, but you can have the bandit choose the nearest one by checking that there's a wall between cover 2 and player.
The HUGE problem I see is that you'd have to tell the TYPE of block cover 2 is made of and keep only the ones that won't allow projectiles through.