Game Development Community

Player State Question

by John Haley · in Torque Game Builder · 09/26/2006 (2:51 am) · 2 replies

I'm trying to start off simple, but have a question regarding more of a long-term goal... would having lots of player states cause any performance issue?

Ex: I'm thinking of something like an overhead action-RPG. Think Secret of Mana or look at this. (Disclaimer: the art won't be that good!!)

So, like Secret of Mana, you can attack in 4 directions, walk in 8. (During the Walk state, you can move diagonally, but still face the same direction.) Also, I want to have different attacks when you first step forward, and have characters run by tapping the same direction twice... so 40 states for motion (10 in each direction).

Example (if facing East)

Stand E ................ Remain motionless / Stop during Walk state ............. Normal Attack
*Step E ................ Move East .............................................................. Strong Attack
*Turn Left N ........ Move North ............................................................ Wide Attack (R-to-L)
*Turn Right S ....... Move South ............................................................ Wide Attack (L-to-R)
*Turn Back W ...... Move West ............................................................. Reverse Attack
Walk E ................. Continue moving after Step/Turn animations finish ... Normal Attack

*Stop E ................ Stop moving during Step/Turn states ....................... Normal Attack
*Turn Around W ... Move West during Stop East state ............................ Two-way Attack
Run E ................... Move East during Stop East state ............................. Charge Attack

*Slow E ................ Stop moving during Run state ................................... Panic Attack

I don't know if this list makes enough sense. Trying to keep it brief as possible.
The * indicates a transitional state which ends when the (~1/4 sec) animation is completed or the player makes a different move, the state will change. Attacks also vary depending on the state, and I THINK this is a good way to pull off that double-tap a direction to run move (seen in old Super NES brawlers).

Naturally, I'll need to add getting-hit states, KO states ("dead" is such an ugly word), eating something states, etc. later on. (Even a state for keyboard users pressing two opposite directions at once!) But for now, I just want to make a guy who runs around properly.

So is there anyone who (1) had the patience to read this post and (2) knows anything about player states?

I can figure out the concept - what a player needs to press/release to change states. I just don't have the slightest idea how to code it.

-John

EDIT- For those of you who checked out my site, ignore the out-dated info about 3D cel-shaded. Obviously, I'm toning it down a bit for now.

About the author

SUMMER PROJECT: Currently working on PSK tutorials. SHORT-TERM GOAL: Make a basic platformer level. LONG-TERM GOAL: Make a co-op platformer in which the two protagonists use their unique abilities to support each other.


#1
09/26/2006 (3:42 am)
Hey there. What's worked for me has been making the player object do the things I want it to do based on control, and then making the player appear to be doing the things that the player object is doing. In other words: I make the player move left when the input calls for it. If the player is moving left, I play the moving left animation. I hope that makes sense.

There are a few exceptions. For example: jumping, attacking, etc. Certain actions like these are tied directly to the animations and can be triggered by a certain frame of an animation. So when the attack animation reaches the striking frame, call the 'initiateAttack' event. If the player gets attacked before that frame, which would change his state and subsequently cause his animation to change, he will not reach that frame so the attack will not be carried out.

I wrote up a finite state machine class in TorqueScript that might help you. Ive used it to power animations and AI so far, but it's pretty flexible. I posted it last week in this thread.

Good luck, and feel free to post with any questions about the FSM class or otherwise.
#2
09/26/2006 (8:15 am)
Thanks. I'll see what I can do with that...!