#Top-Down Melee attacks
5 messages · Page 1 of 1 (latest)
I know about that, but I'm struggling finding out a way to make a melee attack go in 4 different directions around the player, based on the mouse direction, I'm just not sure how the mouse direction can change which way the melee attack goes to, thanks for the tip though
point_direction returns a 0-360 value
and if you wanna convert that to 4 directions, you can take what point_direction returns and divide it by 90 and round it. 0/4 would be right, 1 would be up, 2 would be left, and 3 would be down
Alright, that makes more sense, I'll try that out, thanks for the advice!
function cardinal_dir(_dir)
{
var _d = round(_dir/90);
if _d == 4 _d = 0;
return _d;
}```
I'm making a top down game and I use this function all the time. For example, to decide which walk sprite to display based on an analog stick's 360 degree position. Choosing one of four directional attack animations would be another use case.
I haven't seen your game, but if you're using mouse to aim though kinda like binding of issac, it would be more precise if you used a single "forward" attack animation and actually rotated the character to aim directly at the mouse. That may be a better or worse fit but you won't know for sure unless you try both.