Download

Character swap logic Multiplayer

Hi all, Important question guys lol, im wanting to switch back and forward between 2 completely diff character blueprints at the push of a button. i reckon the easiest way to do it is to have both spawn into the level together and have one with no visibility or collision then switch over when needed, Correct me if this is not the easiest way please. but main 2 questions are…1. would i copy the initiate and spawn pawn logic from base character bp into the new character BP to get them both to spawn in at same time? and 2. would i use the “Base Character PC” blueprint to link the 2 characters to the same controller and flip flop between them both??

Bump, editted my question :slight_smile:

PlayerController -> Posesses Pawns/Characters. So basically, you have to possess the character that you want to control. You can put logic into your player controller class so you don’t have to copy variables to the new character. How you handle spawning these characters is up to you, but keep in mind that if these players are only different in visuals, than you can just update the mesh of your character at runtime.

Thanks for your reply much appreciated. So yes i have it mostly working in the player controller and casting to both the old and new character. The new character by the way is not the same so i cant just change the mesh. Anyway so i can switch between old and new character with the server, but the client will only change to new character but wont change back, im guessing its just a node i havent put in correctly or something small so hopefully i find which one lol, thanks again.

Bump…still lost on this

Well if this is multiplayer you never want to use “Get player (x)” where it uses an index. You’ll also want to assign an owner on your spawn actor. If you’re in your Player Controller, use “Get Controlled Pawn” to get the current pawn controlled.

The logic you have written is a little confusing. I would spawn both on begin play and create “hide” functionality like you said in the post above. Make sure your “hide” event is a multicast, and set visibility and collision of your BP to false. Don’t forget to turn off gravity as well (character movement component i believe) or your character will fall through the world. Do this before setting collision to none. Create a “Show” with the opposite functionality, still multicast.

Then create an event “Switch Character”, server . Check which character they are in. Run Show then possess on the one you want to switch to, run hide and unpossess on the other.

Call switch character on your input.

Good luck!

Awsome thanks for your reply. Yeah im confusing myself as to which way to go about it but spawning both and setting hide on one is what i still need to try out. Just trying to find a good tutorial on a similar goal to help out a bit. Thanks again.