Can't figure out why these casts are failing all of the sudden

While making a few changes a couple of cast to AI_controller stopped working out of nowhere:

And in this one not only is the cast failing but the try get pawn owner is being read as not valid, even though when I print it it seems fine:

Weirdest thing is that a completely unrelated animation blueprint with comepletely different variables also started having this issue.

Hey!

What changes were you making? It might give some idea to what went wrong.

In the meantime you can check if you do have the right anim bp selected in your actor and that the character variable is being set from you actor bp to your anim bp.

Thanks for the help! Everything seems to be in order. If by setting setting from the actor bp to the anim bp you mean this:


Then yeah.
I was just trying to fix some issues in the Anim graph and EventGraph. I Didn’t even open the controller or anything. And as I said, what’s really weird is that a similar anim bp that I didn’t even open and that uses different bps also fails its casts to its controller.
It’s just that the more I look into it the weirder it gets:


Even though This cast is failing I’m still able to recieve the LookingDirection from the Controller and the character behaves accordingly when launching the level.


It’s this second Cast that seems futile, even when I try to bypass the isValid node.

This indeed is extremely strange, do you have different player controllers?

If you don’t, check that you have the correct player controller ( think it is that Edmon Controller ) selected in your game mode

If you do check that you are assigning the correct controllers to the appropriate actors.

Also, I wouldn’t cast to the player controller on each animation update, casting should be used sparingly. Try casting to the controller after you casted to the Edmon_NPC on the Initialize Animation event.

Use the Edmon Character Variable and try get controller from that and set that as a variable, then you can use that to get your variables needed to update the animation.

Yes, the correct controller class is assigned to the actor.


I believe the main issue is that the Get Controller From Pawn isn’t working. Probably something to do with the character bp. I did change the controller to none for a moment to test a thing but then I changed it back.

Yes, I just though of that and changed it. Which is how I found out that the Edmon Character variable is valid but the return of Get Controller isn’t.

Yea that is wierd, might have to do a bit of debugging to see if the controller is properly getting assigned to the character.

If you would like you can share the project files with me and I can take a look from my side.

1 Like

That would be extremely helpful and generous by your part. If I don’t seem figure it out I’ll porbs share with you the files.

1 Like