Cast to Character failing

For some reason I am getting Cast Failed when I try to Cast To Character in the event graph of my animation blueprint. I’m still pretty new to Unreal so I must be missing something basic.

The section of the FPS tutoral for setting up the animation blueprint event graph can be found here:
https://docs.unrealengine.com/latest/INT/Programming/Tutorials/FirstPersonShooter/4/2/index.html

Is there any reason why Cast to Character would fail in this situation? Where could I look to start hunting down the problem?

It says the compile was successful and I don’t see any errors listed in the Compiler Results window below.

Make sure you are using a Character and not a Pawn. Make sure your character Anim Blueprint is set correctly inside the Characters Blueprint properties. Run your “Try get pawn owner” output into an “IsValid” node and print string if it is not valid.

If it still can’t cast to it its either pending kill, destroyed, never existed or of the incorrect type. Let me know if that helps.

just a thought… also make sure your cast node is casting to the correct blueprint (i.e. that if your character’s BP is called “TomBP” that you cast to “TomBP”

The character blueprint’s FPSMesh (Skeletal Mesh Component – the hands of my first person perspective) is set to use the animation blueprint. I added logic to print a message if “Try Get Pawn Owner” is invalid, but nothing is being printed and the functionality seems to be working because my state variables are being updated as reflected in the animation. However, it still shows the bold red line flowing into the print invalid error node.

Is it possible that it’s only invalid when the game isn’t running? If I hit Play in the main window and then Eject (F8), then click the animation blueprint (still showing the bold red flow going into invalid print message node), then back to the main window again, it will show a handful of the invalid messages on the game screen but only for a couple of seconds before disappearing.

Noted. I have a C++ class which inherits from ACharacter and then created the BP character class from the C++ class. The BP character is set to be the Default Pawn and I made sure the cast is to the blueprint type as well.

Hi jr557, check out the default first person template (below). Yes, the owner is not valid within the editor. To check if you are having problems hile in game use the LiveDebugging feature in the toolbar, select the running instance and you can view what is happening live within the graphs.

If you feel that your question was answered, please mark it as resolved to assist other developers with similar problems. If you still experience this problem in game let me know. Thanks.