in animation blueprint my boolean doesn't update

hi, i have a pistol and i want to when pistols ammo comes to 0, change it to the zero ammo animation. i created the boolean and i check it from uelog and it is working(when ammo goes below 1, returns false) but the animation stays and never changes

hi @BioFrost.in

That boolean needs to be set using your Event Graph in your animation blueprint.

All updates are made during the “Event Blueprint Update Animation”, so somewhere in that event you need to get the Boolean value from your character (or wherever it is stored) and set “Has Bullets ch” to that value.

bhasbulletsch


is this correct? still doesn’t work

Where does has bullets get ch updated from? Normally you would store this in the character , then you get this from the character and set it to " has bullets" which is correct

Let me know where the original var is stored

Im out for a few hours if you still stuck when i get back i will show you how my character passes vars to anim blueprints

i have a function in gun class called IsEmpty() this returns a value and in AnimInstance.cpp i get this value store it in bHasBulletsch that created in animinstance

So you need to be able to reference this class instance from inside your animation class. Get the value during the uodate event. But i dont see you referencing the gun class to get the variable

how can i cast to AGun class? animblueprint says it doesnt inherit from character, can you share with me a example reference

i can only show you how it works in blueprint as i dont use c++ but the idea behind it should be the same.

Your character has a number of components, capsule, skeletal mesh etc.
Your gun has to be attached somewhere to your character, and referenceable.

What you could do is add a boolean value to your character say “bNoAmmo”
when the gun itself is out, it gets its parent actor (character) and sets the bNoAmmo boolean to true.

inside your animation blueprint you then need to get a reference to your character, then Get bNoAmmo and set it to your boolean inside of your animation.

so in general the gun tells the parent character its empty by setting the characters ammo boolean…

every animation update get the boolean from your character in the animation blueprint.

If the gun is a component of or referenced object of the character then you can get that direct as long as you can get the character reference.

ok look at this i explain it only basic mind!

In my animation blueprint i have made 2 object reference variables

  1. Character reference
  2. Character Movement reference

and a speed variable

3.Speed

when i initialise my animation (top event) i set those variables using try get pawn owner, then cast to the character type (mine is BP_AI_Zombie)

set my character then get that characters movement component and set that

my animation blueprint knows all it needs now

at the bottom every animation update i check first my character is valid. then i get its velocity, then sets my Speed variable to handle my blendspace speed input
all you would need to do in that section is check the character is valid, get bNoAmmo and set Has Bullets or whatever you finally call your booleans

now in my animation graph i set my speed into my blendspace