Reformatting my character-swapping system?

Hello again, so recently I’ve been working on a system for swapping characters in-and-out with the press of a button, with each individual character corresponding to a different button. I’ve managed to get the core concept working with one of the characters but I still have four other characters that need to be dealt with. Rather than copying & pasting the code four times which would be extremely inefficient, particularly if I need to modify the code which I definitely will at some point, I would prefer to simply things so that each character can be called from a singular source. However, I’m not really sure what would be the most efficient approach to , in particular an issue that I need help with is particular custom event highlighted in red:

The highlighted custom event is responsible for the Player Controller possessing the newly spawned character as well as transferring my custom camera setup from the old character to the new one.

Currently, custom event is located in each of the individual character’s blueprints but I would rather remove it from each individual blueprint and put it into something that be accessed by the each characters from a singular source. I was thinking of using an Actor Component that could be attached to each character but I do have some concerns about going in direction. In particular, I’m worried about the fact that the current setup relies upon getting reference to the character’s mesh. Is it possible to reference a character’s mesh from an Actor Component?

I hope I’m making sense with all of , and that someone can help me out.

Thanks in advance!

Hey Hungry_Moogle,

sounds like a good candidate for making child blueprint classes. Set the logic that will be global to all of your characters in a single blueprint class, and then if you need the characters to have their own logic aside from that simply make a child for each of them. They will all inherit any changes made to the parent, keeping you from having to copy and paste or do things over and over when you need to make a change.

To make a child blueprint class, simply right click in the content browser, click blueprint class, then pick the blueprint to be its parent. Once you make one, you can just duplicate it for each character before making changes that may be specific to each.

I hope helps, and good luck!

1 Like

Sorry for the delayed response, anyways, I’m a bit confused about your suggestion of using child blueprint classes. I’m familiar with them as I’ve used them a couple of times in the past but I’m not sure how to use them to remove the ‘Reset Camera upon Event Begin Play’ coding from each individual character blueprint into a singular one & how that singular blueprint is connected to each of the playable characters.

Can anyone please help me?

Make a character blueprint BP_Character_Base that extends ACharacter (native).
Put your function in BP_Character_Base.
Reparent all your other characters to BP_Character_Base (instead of ACharacter).
Now all your “real” characters inherit from the function in BP_Character_Base.

|- ACharacter(native)
   |- BP_Character_Base
      |- BP_Character_A
      |- BP_Character_B
      |- BP_Character_C
      |- BP_Character_D
2 Likes

Sorry for the belated response but I tried your suggestion, unfortunately though, there’s an issue.

The coding for transferring the custom camera blueprint from one character to another requires a reference to the character that the camera is supposed to follow.

image

I’m sorry but I’m not entirely clear on what you mean by .

Is the fact that the blueprint that all the playable characters are supposed to be parented to being itself parented to the Player Controller blueprint a problem?

No the PlayerController is not a parent of Character, nor the other way around.
They are linked together through code, but not through inheritance.

Make your character base(master) class a child of Character instead of PlayerController.

1 Like

Okay, that worked. Thank you for the help!