Imagine I am making a zombie character like in Resident Evil. For instance:
-
They should move towards the player and grapple onto them when close enough.
-
When the player shoot the zombie’s leg, they should fall down. They cannot move towards the player or grapple onto them while falling.
-
Once they hit the ground, they should start moving in a crawl state and can now grapple onto the player again.
Here are the ways I can think of theoretically doing this:
-
I can have the animation blueprint read variables from the character class, and when the zombie’s “CanWalk” variable is false, make them fall and then crawl using the state tree.
The problem is, how can I know when the zombie is able to “grapple” again? I can switch it off when they aren’t able to walk, but to turn it back on, I need to either set a timer in the character blueprint and try to make it match up with the end of the fall animation (which requires fine tuning and has to be updated if I change the animation), or I can call a function in the character class from the anim blueprint, such as “OnDoneFalling”, but this violates the read-only functionality that I believe an animation blueprint should have. -
I can play a “falling down” anim montage and use the “finished” callback to know when the animation finishes and switch on a “CanGrapple” variable when it does. This may work, but I also may have to rethink my character class design to revolve around a state pattern. This is because I have to know things like “are you already falling? Don’t play the falling montage again!” which is much easier to handle via states in the animation graph but I digress.
I also run into certain bugs that occur due to interrupting montages or having the anim graph not process state transitions while a montage is playing (having the character stand up for a frame after the “falling” montage finishes then falls right back down to the “crawling” animation) but perhaps those can be worked out.
This is my thought process so far. Sorry if I was rambling but I hope my issues are clear and let me know if I need to explain myself more.
Thank you!!