I’ve got an enemy that is a kind of insect alien with six legs and a looping sound of an insect crawling. I want to play this sound when the alien is playing the walk animation. I can’t do dynamic footsteps due to it being a looping sound and I can’t play the sound by doing something like if ground speed is greater than 0.1 because it also has an attack that lunges toward the player and don’t want the crawling sound during that attack. So I specifically need it to only play when the enemy is playing the walk animation. Is there a way I can get the current playing animation and trigger the sound that way? If not how else could this be done?
I’ve sort of figured this out. I set a notify on the entered state event. Only problem is it can only be called in the animation blueprint. I can be accessed in the character blueprint but the event won’t fire from there. Is this the expected behavior or have I got to do something to get it to fire in the character blueprint?
Hey @MarkAntony88!
Have you tried “TryGetOwner”->CastTo(whatever the owner’s BP is) → Use a custom event on the BP to start/stop the sound?
Give that a try and get back to us!
Probably not the answer you were hoping for, but your best bet would be to edit the looping walk sound, and trim it down to a single footstep. If there’s some varation to the steps in the loop, duplicate it first and isolate a few variants. Then play them dynamically with anim notifies. While it’s a bit tedious to setup, this really is the only way to get the steps to match the animations when blending between different speeds or attacks. Additionally, when doing it this way, you can add logic to the notify events to check the surface being walked on and select which sound to play. Which is handy if, say, the right feet are stepping on carpet but the left are on tile.
I can make a custom event in the character blueprint and fire that event from the anim notify in the animation blueprint.
So can animation state events not be called in the character blueprints regardless of being able to access them in the character blueprints. I’ve also just noticed that the anim event I put on my enemy can be accessed from any blueprint even if it has no relation to the enemy. Is it a bug or is all of this expected behavior?
Not sure there’s really an elegant way to directly access the anim state machine from the character. To force the walk state to end during an attack or whatever, easiest thing to do would be to set an “IsAttacking?” bool or something on the char, quey that in the update animation event and use in the transition rule to go back to idle. Could end up with some sliding though as char goes back to idle before movement stops. Either way, the looping walk sound is bound to end up desyncing as the enemy changes speed. As mentione above, probably best to chop up the loop into single sounds.
The space crab is adorable, btw.