8 Direction Combat System

Hi!

I’ve currently setup a 4 direction attack + block system in my game, which is a first person melee game. Basically I compare the x and y movements of the mouse with their absolute value, which gives me 4 directions. Any ideas on how to expand this into 8 directions?

Thanks!

Nevermind, I figured it out! I just branched off the Compare Float node to check the other direction!

For the future, you can do the following:

  1. Create an vector from mouse position
  2. Calculate Rotation from X-Axis
  3. Get Degrees / Radians of that
  4. Divide (integer) through (360° / direction count) or (2PI / direction count) Generally Speaking dividing through size of one circle segment
  5. Now you have an integer reprensenting the segment you are in, which i would cast to an ENUM (note the enum needs to be in correct order for that to work)

Hmmm, interesting. Right now I do the following;

  1. Compare abs of X and Y to determine the mouse direction (X or Y), sends a bool to a branch.
  2. Compare the original axis value to get the respective direction.
  3. Then branch again (twice) to compare whether or not the axis is > or < to get the direction.

I’ve decided to go with a 5 direction combat system instead after some thought.

How would you compare this method with the method you described? I’ve only just implemented mine and it seems a little dodgy, but I need to check values and whatnot.

Thanks for the help!

Scratch that - sorta.
Now, instead of comparing the x and y axis at the beginning, I simply get the Y axis, and compare whether it’s going left or right. This gives me six axis to work with and seems to work great!

Ive been struggling so bad to get something like this to work.

Any chance you can bestow upon me some wisdom and guidance on how you got your 4 and 6 directional combat script to work out?