As seen in the picture below PlayerCharacterBP DOES inherit from BaseCharacter_BP. I also use it’s functions and variables so this is a bit strange.
I found this post from 4.10: https://answers.unrealengine.com/questions/339295/erroneous-cast-would-always-fail-warning.html where it was logged under UE-7303. But how can I check the status of UE-7303 and has this still not been fixed?
It’s the wrong way. You can cast the inherited class to baseclass, but the other way isn’t possible.
The parent class doesn’t know which classes inherits. The parent class doesn’t have the properties and functions of
How the Cast should work? The children has all public and protected properties of the parent.
Maybe you’re looking for a boxing and unboxing mechanism.
Ah indeed. You can’t cast the class to it’s child-class, only to it’s parent. Makes sense.
I could of course have a variable in BaseCharacter_BP of the type PlayerCharacter_BP and set it in the PlayerCharacterBP constructor so I have a reference to it from the parent. But that looks kinda silly.
How do I box/unbox in Blueprints without using C++?
it should work with the buildin types. take actor and cast it to your character.
Example: A Trigger gives you the other actor and you can cast it to whatever you expect.
In other languages you haves types they’re like boxes.
object mybox = mytype // boxing
mytype = (MyType)mytype // unboxing you know the type you put in the box.
i hope it’s understandable.
The build-in types work. But the whole thing all together is strange at the very least. Also there is a case where you cast parent–>actor–>child where the engine gives me a warning about parent already being an actor and thus there should be no need to cast it to one. But I HAVE to cast it to the build-in type in order to cast it to a child-blueprint. Bug or me?
Casting from Actor → child works.
Casting Parent → Child always fails.
But casting Parent → Actor → Child only warns me that Parent is already an actor and that I do not need to cast it to Actor. Even though it should be the same as the above line. But it is not???
*Edit, doing what you recommended did not fix it for me… but updating to 4.24.2 magically did…
old post: funnily enough i had gone all the way from 4.14 to around 4.21 using this parent cast to child and it worked with no warnings but now in 4.24 it warns me about the cast failing. glad i came across your post , in this case i’ll do what you did and cast from parent to his actor type and cast to the child… should work as you said…
epic needs to fix these important bugs before adding any more features for Magic Leap and ansel photography and all this stuff that no one uses
okay so this explains how to get around this. hope it helps someone out.