Why would this cast fail when its connected to an input action, but not when its connected to anything else?

Hello! Im trying to do a simple cast to another Character Blueprint, but for some reason, when the cast is connected to an Input Action (In this case the R key) It does not work! I added these Print Strings to check when the cast fails and every time i press R i get “Bye” (Cast Failed.) the strangest thing here tho is when i plugged the cast node into beginplay, the cast worked! displaying “Bye” and “Hello” at the same time but ultimately working. Can someone explain what is going on in here? And yes, the Character Reference variable IS actually a character reference and BP_Dozer is parent class Character. Im stuck!

Hey @Cloak_Enjoyer

is your character reference valid? Can you show where you set this reference?

displaying “Bye” and “Hello” at the same time

Do you use the CastToBP_Dozer node anywhere else?

1 Like

Hi! thanks for answering. Im pretty sure it is valid, and no i did not use CastToBP_Dozer anywhere else. But when that node is plugged into beginplay i get both messages at once.

Hey @Cloak_Enjoyer

these are the settings for your variable. With this you create an empty placeholder. Then you have to set it:

IsValid can tell you if this CharacterRefence is/was set.

E.g. you can do something like this:

  1. An Actor overlaps a SphereCollision
  2. We check if this OtherActor is of type BP_Dozer
  3. If it is of type BP_Dozer and the cast is a success => Save this BP_Dozer as CharacterReference for later use

You need an actor for your CastTo node and for this you can use Overlap events or GetAllActors

(don’t use it when you have tons of actors in a level) etc..

1 Like

Your screenshot shows that the reference is empty, thus null.
Are you Setting it in code?


Every instance of the class executes Begin play. The servers copy, Autonomous and Simulated.

One player in multiplayer setup would print 2 messages.
2 players in multiplayer would print 6 technically one per proxy per Instance.

I can cast perfectly now :smiley: thanks!

1 Like