u/Different_Stranger30

NPC AI interacting with FSM (movement, actions, whatever)

Hello,

Sorry if this is a dumb question.

For context I want each actor to have a FSM for things that a FSM makes sense to solve like movement, and I want a player to be able to swap between certain Actors in a party system. Except, how do I have an AI interact with that system?

The only idea I could think of is that each state could have a list of their potential transitional states, a function to query those states for the AI to call, and the function that handles inputs can either take in the players input (say spacebar for jump) or the AI's input (just the Jump Enum). Is that a reasonable method, or is there a more obvious solution?

reddit.com
u/Different_Stranger30 — 4 days ago

Guidance on Implementation of a Hierarchical Finite State Machine

Hello,

I'm new to GameDev and don't have a background in software development so sorry if this is a dumb question.

I have built an FSM using this video as a guide: https://youtu.be/K9JizfQ-oFU?si=EPgMUu7r_a5EWFr0

I want to extend it into a HFSM. My plan to do so is:

  • give states a "state parentState = null" variable in the parent State class
  • Update parentState on creation of sub classes where applicable, such as the "airborne" superstate for the "jumping", "double jumping", "falling" substates, etc.
  • Update the StateMachine class functions to also call parent states if that state is not null.
  • Do some sort of shared parent check prior to calling parent classes for transition functions, like enter and exit. Thinking a hash table check for a shared parent and if it comes up with a value keep calling the enter/exit function on sub parents until reaching that value.

Does this seem like a reasonable way to turn that code into a HFSM? Am I missing any concepts or issues in my idea?

u/Different_Stranger30 — 12 days ago