Cast "saved" Metahuman to Default Pawn Class

Hello, to start off im very new to unreal and im not sure if im posting this in the correct area.

So I am creating a character selector using metahumans. I have my code to “save” the selected character and “load” the saved character in a new level and im trying to cast the loaded character (metahuman) to my default pawn.

All of my metahumans have been made children of the thirdperson character with all the proper blueprints copied, so all of these metahumans are fully playable as the default pawn.

As of right now to load the character i have a Begin Play event going to my Load Character Data function which goes to a Spawn Actor. This part works and my saved/loaded character spawns in the new level. The issues im arriving at is setting this loaded character as the default pawn. How would I go about doing this?

Select a default pawn class in your game mode:

image

My Products

Yes I already have a default pawn class for my game mode

Have you set your gameplay to your project or the desired level?

image

image

yes, both of those have my game mode

I’m not sure what you mean by “setting this character as the default pawn” after you already spawned it in. If you mean you can’t move, you could try possessing the actor with your player controller.

Yes I apologize this is what i mean. So I have my “SpawnActor” node, from there ive tried a “Cast to Character” node going to a “possess” node. Target is the player controller and the “in pawn” is the “as character” from my cast node. does this seem right?

Well, yes, that should work. You could probably also just pull straight out of the spawn node and plug that into the in pawn as well. You don’t need to cast there unless I’m misreading something.

As to why it isn’t possessing, I’m unsure. It isn’t stuck in a wall or something right? To test, try setting the specific character you are trying to possess as the default pawn and then putting in a player start instead of BP spawning. It could also be something wrong with the character, so it is good to double check that spawning from anything at all works.

The return value of the “spawn actor” doesnt plug into the possess “in pawn” because its an actor object reference not a pawn object reference.

I can play with all of the characters im trying to spawn just fine if i set them as the default pawn to start with, just for some reason its like my controller isnt working on the characters when I spawn them from the blueprint.

If you need some screenshots of code im more than happy to post.

Thank you for the responses by the way!

I think I may have found the problem. You may be using a different spawn node than normal perhaps. Usually it can be plugged directly into possess. Does your node look anything like this?:

Also, yes, feel free to post screenshots. :slight_smile:

Hey thanks for the response.

Yes my node looks like that. My class is connected to two reference pins on my “load character data” function. The world transform is connect to a get world transform node on my game start. And the return value for some reason cannot be plugged into the “in pawn”.

When I get home I’ll send some screenshots, thank you again for the help!

Ah. I see now. You could try putting the cast before the spawn node instead of after it. It would be a class cast. Something like this:


So this is with the cast set before the SpawnActor node. Im still having an issue controlling them. I can select any metahuman and they all spawn but no luck with the movement

Yeah, I’m not sure what the issue is either.

This is a complete longshot, but the only thing I’ve seen that is similar to this is when people can’t use their spawned AI. You aren’t using an AI controller, so this shouldn’t do anything, but just in case maybe go down to the “pawn” section of the details panels and select “placed in world or spawned” from the dropdown.

That setting is selected already. This has stumped me for the last week lol.

Is there anything else in my code you want to see? I mean it might not help since every other line of code is working, its just the possessing and controller not working.

In case you’re curious I tried looking at a tutorial from CodeLikeMe on character selection. Its basically what I did except he uses skeletal meshes where I use Metahumans.

I wouldn’t think skeletal mesh vs Metahuman would matter as long as the actor itself is a possessable pawn. I don’t know much about metahumans, but I assume they are just actor components like any other kind of mesh, right?

Heres some photos of my blueprints. my CycleCharacter, UpdateCharacter, and SaveCharacter. LoadCharacter is essentially the same as the SaveCharacter, and I also have a gender select

I think it would be best to figure out if it is some issue with the characters or some issue with the possession getting through.

Try putting some on tick print stings in one of the characters. Have one print the gotten controller currently in charge of the pawn and have the other print regular “get player controller.” Use different colors for the two print strings and see if they are identical. If they are not, then you know it isn’t possessing the pawn.

If they are the same then it isn’t the possessing that is the issue.