Cast Failing all over the place

Does anyone know why this cast could or does fail? I have used this method a tonne of times with no issues. I am having a similar issue with my get player controller cast to my player controller. I have another project where I do the exact same thing and it works!

Is there some fundamental thing that I am missing in this project compared to others?

Thanks

When you open the Player Character Base blueprint, what does it say about its Parent class: in the very upper right corner?

Apart from that, ensure there is a character assigned in the GameMode.

Hi - all it means, is that THAT player character is not of type PlayerCharacterBase.

Please double check :slight_smile:

Character

It also happens with the game instance, which is definitely a game instance.

The get player character node is a function that is linked to the parent class of the “Character” class. So the PlayerCharacterBase could well not be a “Character” class which would cause an issue, but it is a character. So the get player character node should be able to call the character I have made because it is of the character class.

It is also happening with the player controller which is of player controller class.

Both of which I have used several times in other projects and been successful.

Can you try this on the fail?:

( imagine it’s the right kind of cast :wink: )

Can’t cast to GameInstance → it was not assigned in the Project Settings

Can’t cast to GameMode framework elements → the level you’re in is not running the correct Game Mode.

Worth double checking if all else fails.

So I tried the exact same thing in the Third person Example project and it works how I would expect it to work, so I am clearly doing something wrong in my project somewhere that none of my casts are working.

I just need to work out what is happening in the third person example that isn’t happening in mine.

298994-screenshot-2020-04-02-at-135131.png

Thanks, I already set up the Game instance in the project settings and set up the game mode while I was there, did this at the very beginning of the project before I started doing anything else.

So both those should be working as intended.

You could print the class type name. This could help for further investigation.

Right, I have absolutely no idea what I did between last night and today, I deleted all my code, re-did all of may variables and it seems to work!?..after doing it in 2 other projects.

I have no idea what happened? Maybe the editor had a melt down I had been working in it for 12 hours straight.

Anyway, thanks to everyone who offered their help and advice, I wish I could tell you what solved the issue but I really have no clue at all, just re-opened the project re-did the casts and they worked.

Thanks for your time, no idea what happened but it seems to have resolved its self and allows me to use the exact same casts successfully now after a re-boot of the engine.