need help with accessing variables

i have a ‘footstep volume’ float variable in my bp_thirdpersoncharacter and i have a bp_footstepanimnotify that adds notifiers to my animations for playing the footstep noise. how can i access the footstep volume variable from bp_thirdpersoncharacter and change it in bp_footstepanimnotify ?

In your Animation BP Event Graph you can reference your character class and get the variable.

Best served if you create a float var in your Anim BP and use the characters to set it.

Note The Event Blueprint Update Animation executes once a frame.

i tried something similar to that but any time i add a reference to the character i get an error saying its read only

heres a screenshot

Get Owner > Cast to Player?

unfortunately it doesnt seem to work. the variable in the bp_footstepanimnotifier doesnt let me change it to a ‘set’ variable and it says it is read only

this is what i have so far. im trying to grab the variable from the character bp and set it with the value of the variable in the animnotify bp

you cast then just get the footstep volume of the character. dont need to set. or do you want a different volume for different surface?

yeah so basically ive got the footstep volumes set up and i want to change the volumes of them based on the player state (like walking, sprinting, crouching etc) but those states are initialised in the character bp. so i set the footstep volume in the character bp when the player is in those states and i just want to translate that value to the anim notify bp that holds the logic for initialising the footstep sounds.

I see what you’re doing now. You’re using the Anim Notify Class which has no direct ownership to the character. It’s an independent data asset with functionality. The Animation Sequence executes the Notify Class and passes the mesh component obj ref. You can use that to get a reference to the character.

Overall This is BAD! Your casting to the character class N times a second.

You’re better suited to handle footstep sounds directly in the character class or in the animation class.

This example handles them directly in the Animation class.

Parsing the surface type runs through a primary data asset. Whish returns the Meta Sound Preset.

Presets are MS Data assets.

Presets execute the Meta Sound source

1 Like

oh wow thats a lot of information. i understand it better now. ill try to use these methods to the best of my ability. thank you for explaining.

oh my lord i accidentally found another solution to my problem while adding a new feature. basically im making a dbd style game and wanted to add a sound when fast vaulting. i clicked on the footstep anim notifiers on the animation and found that you can individually change the sounds of each notifier. lmao i feel kinda silly now, but still, thank you for all your help.

edit: ( this was possible since i made the footstep volume variable in the footstep anim notifier and linked it to the volume multiplier nodes on all of my footstep sound effects, so i could now just edit the variable in each animation that uses the notifier.
therefore, i can set the default value as my walking speed for example, and then just manually change the crouch notify volume and running notify volume. )

If you’re having to cast to your character or any other heavy class it’s going to hit performance. Notifier class is fine for things that aren’t overly dynamic. If I used them for Footsteps I’d probably tank 20+ FPS right out of the gate. They are perfect for things like racking a shotgun, mag reloading, button toggling.

1 Like

i see, ill keep that in mind if my performance starts getting worse as my project goes on. but as for now it seems to be performing well and working as intended. thank you again for the help and knowledge.

It’s mainly a matter if you’re doing multiplayer or have a lot of AI. How much casting your doing with other classes. If dead set on using them I’d setup interface functions to pull the data needed.

Create a interface function in the character interface class called Get Volume. Have it return a float. Dbl click it in the character class and pass the float to the return.

Then in the notifier received function mesh comp → Get Owner → Get Volume

No casting. If there’s other data you’ll need then create a struct and have the function return that.

1 Like