Just to give you a correct answer (you already found out in the comments): you are trying to cast a PlayerController
to Cube
that inherits from Character
or Pawn
. They are incompatible, so the cast is always failing.
If Cube
would be inheriting from PlayerController
instead and defining a variable Health
, then this would be fine. But this is not the case and you should not change it to that.
The solution would be that you retrieve the pawn the PlayerController
is controlling. You can do that with the [GetControlledPawn][1] function. After that you can cast it to Cube and do stuff.
Alternative: you are using GetPlayerCharacter. This retrieves the Character directly.
Here an example blueprint: