States

Working on a game states, much like animation states but to recognize if a character is
a. on ground
b. midair.
c. wallrunning
d evading
e. parrying
just so to tell their hitbox or animation to behave differently? In a press of a button for each?
How should i approach this problem?

I find most people use if else, if else, but i’m not sure how to store these states.

The easiest way is to just use an Enum. Or you can build this sort of thing into your Animation Controller.

As an example, you might want to study 2D Animation Methods in Unity. This illustrates a couple different ways to keep track of a character’s state: doing it yourself with Enum and code, doing it entirely with Unity’s animation state machine, and a hybrid of the two.

Even though the article is about 2D, as far as state tracking goes, it would be exactly the same in 3D. The only difference is that in 3D, you are more likely to be morphing a mesh or otherwise interpolating between poses, which pushes you in the direction of using the Animation Controller.

Best,

  • Joe
1 Like

You also want to check out the concept of a finite state machine

Good question, for the physics forum.
Gigi

Interesting, although i am not sure if this is just about physics engine…

Just gonna put this here as reference…

This game of ours is still starting early, so it won’t be as fancy… with polygon budgeted at <500 tris and minor texture,
we hope to practice lotsof engine related things…

It seems like after trying our hands at our first prototype, it seems like the very first place to start is here, by using a
box and debug.log, and try to press all kinds of buttons possible and callup the basic functions first
using if else, switch cases or dowhile?
And connect them to possible physics manuever…

It seems we also have to make some basic animations,
since otherwise we can’t really practice the state machine in animation with a box…