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
the children.
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++?
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…
I am getting Unreal Course and the lecturer did cast from the parent class to the child class. How did it worked ? I searched a lot and the answers the I found as you said. But what lecturer did confused my mind. Do you have any idea about that ?