Beginner very confused at the moment. I have made a few animation blueprints before and have not encountered this problem. The blueprint in the screenshot below serves as a visual only, its not really a part of my project. The problem persists across all animation blueprints in my current project.
So, the problem is that “get” functions like Try Get Pawn Owner or Get Player Character do not work, they return None. I am able to cast to ThirdPersonCharacter (and everything else) normally from controller and other actors for example, so casting does work elsewhere. Yes, I have a character class actor that gets possessed automatically and it is set as default pawn class. I have tried both placing it in the world and spawning it through player start.
Now, this is where it gets even more confusing for me. The thing is, this animation blueprint above DOES WORK. The variables you see (Is Falling? and Speed) get updated correctly, and work in the state machine. Why? Shouldn’t they remain false and 0 as the functions before them in execution return None and are not valid? Yet I can enter jumping animation and running animation etc just fine.
Where exactly do they get the values from? This is every node in the event graph.
I have made animation blueprints before just like this and they have worked well. Any ideas where I could have gone wrong with this project?
I’m hesitant to mark this post as solved as I do not understand why the solution above is incorrect, and the solution below works correctly. What exactly is the difference here?
I can’t answer this question but you might be previewing the editor character on that image? Possibly IsValid does not return true for a preview even though the pointer is usable. Anyhow, i wouldn’t consider your second working setup safe because it only checks for the validity of the third person character once during BeginPlay and assumes the pointer is still valid at any other moment UpdateAnimation is called.
I rather avoid delays at all costs because you take your logic out of the natural “order” it would be in otherwise. I think you should remove the logic on the image entirely and work with delegates, using the observer pattern:
Create an event dispatcher on the character “OnAim” with a boolean parameter.
Create a setter method on the character “SetAim” which sets a bool “bAim” and broadcasts the OnAim event using the bAim value as an argument.
Create a function on the Anim BP Called “ActOnPawnSetAim” with a boolean parameter.
Your new logic would look like:
Anim blueprint BeginPlay:
1.1 Set a pointer variable to the owning character. it must be valid, else we seek alternative.
1.2 Bind the Anim BP method ActOnPawnSetAim to the event dispatcher OnAim of the character.
now every time the character sets that aim bool through its setter, the method on the animation blueprint will be triggered. This means you don’t have to check each tick and you don’t have to keep track of pawn validity.
If you drag that red pin and type “create event” it will let you choose a function of a compatible parameter signature. That’s more useful in ways than that event node shown on that video.
your implementation is OK exactly what I meant. I prefer methods over custom events because methods don’t clutter the event graph and have some additional options like access specifiers. The only downside of using functions over those graph events is that you can’t use async nodes like delays in them. * oh and you can just make a binding to a method on a parent class and override that method on a child class, lot cleaner than having many events on one page.
Thank you so much, this has been a massive help. Even to my beginner eyes this is clearly a much better approach to animation blueprints and communicating between blueprints.