I am unable to switch to a second character when it is spawned during the instance?

Hello,

In my game you can switch between characters like you can in Lego games. However, unlike Lego games, the second character is not always on screen and instead gets spawned and de-spawned in to the world. The first image shows “BP_TESTSpawnDead” which is able to spawn the yellow guy but does not let me switch to him when I press “R”. I am able to switch between my two character if I have placed them both in the scene before I press play.

This second image shows the “BP_TESTSpawnDead”. It is a temporary blueprint to check if I can switch between my characters if one is spawned in the instance like it will happen during my game.

These are my characters with there parent child relationships noted. BP_LLN_McMain and BP_LLN_McElectric are the two shown in the level. The Player Controller contains the switching mechanic

These next two images show the Player Controller. The Player controller contains the Switching characters logic. I learned it from a video from Ryan Laley.

I have tried to get a reference to the game mode after spawning hopping though that did not work. I also changed the “Auto Possess AI” which didn’t work. I didn’t think it would but I tried it still.

If any one has any suggestions as to how I should proceed I would love to hear it, or if you need more info I can provide I will of course be happy to do so.

I think the problem is that… You are finding the characters on begin play but you are not spawning all the characters in the level on begin play but on a collision therefore the “Roster” does not have the character that just spawned in…. preferably move the find actor of class in the switch character function so it indexes all the new characters that might have spawned in before the keystroke…. or if it was up to me I would add use delegates to send a delegate that the specific character is spawned in… this method is better if you are making like a puzzle game or level system game where you need to make sure the character spawns in before dealing with multiple blueprints … it will be more manageable and better for long term.

OR

if you wanted to use the array as all possible character blueprints then “find all actors of class” is not the function to use, cause its made to find actors in the world or map, (this method is not good it will only cause trouble ahead).

Let me know if this solves your problems. Cheers mate!

can you close this thread if your code is working now…

Sure thing. Thanks for the help