Internal AI FSM transition from an external Raycast's results

Started by
1 comment, last by Whorse 9 years, 11 months ago

I'm making good progress on a shooter I've been working on for the last few months, I've now moved onto the AI. Currently I perform a Raycast from my base Weapon class to check for impacts, and then invoke a function on the hit object after performing the necessary checks.

I've implemented an FSM pattern for my enemy AI and I'm having trouble coming up with an elegant solution to transition to a HurtState from another state to perform hurt animations and to momentarily stop the enemy's movement.

Since the states check their transition logic internally every frame it seems counter-intuitive to force a transition to the HurtState externally. What's the best way to achieve what I'm after without hacking something in or am I thinking too much into this?

Advertisement


Since the states check their transition logic internally every frame it seems counter-intuitive to force a transition to the HurtState externally.

If your FSM already checks its internal state every frame(hp<threshold => transition to hurtstate), then you just need to modify the decision attributes when reacting to an external event ( hit trigger => hp -= dmg).

Keeping it internal like you suggested led me to compare the previous frame's health with the current health. Depending on the amount it had changed, I trigger different animations or death.

This topic is closed to new replies.

Advertisement