Why does casting fail when c++ function called in blueprints returns c++ base class of blueprint child?

I have created a funtion in C++ that returns a class (myBasePawn) which is a child of pawn class. In blueprints, I have a pawn class which is a child of the “myBasePawn” class (myBasePawnBP). The function that returns “myBasePawn” is blueprint callable. When calling this function in blueprints, I successfully get the object i need, but casting that object to “myBasePawnBP” fails. Instead, i have to cast it to “myBasePawn” in blueprints after which it succeeds. But the game uses the “myBasePawnBP” class. So why would this cast fail?

If you have a method in C++ that is BlueprintCallable, and it returns a pointer to myBasePawn, then in Blueprint it will only be a myBasePawn. C++ has no idea that there is another base class of myBasePawnBP, so once you use the BlueprintCallable method, you lose information that myBasePawnBP contains, and only those that remain with myBasePawn exists.