Changing Movement Mode affects other characters

Hi everyone,

I’m working on a game where you can switch between 3 characters at any point during runtime. The 3 characters are children of a master character BP and share the same functionality. This master character BP is based on the ThirdPersonBP from the normal template.

I have a CharacterSelect blueprint with the following functionality:

On Event Begin Play I get the references to all characters in the level like this:

Then when the Player presses 1,2 or 3, it possesses the appropriate pawn:

I also have a simple water blueprint that changes the Movement Mode of the Character on overlap:

Here’s the issue:

When Movement Mode for one character changes, the Movement Mode for the other 2 changes as well as soon as I possess them! If I jump and switch in mid air, the character STAYS in mid air. If I set the Movement Mode of one character to Swimming…the Movement Mode of any possessed pawn will also change to Swimming.

Is as if the Character Movement that I reference is changing at the parent level and not the child level (even if I specifically reference the child)

Please take a look at this 1min video to see what I’m talking about: [Youtube Video][5]

Can anyone tell me what Im doing wrong here? I want to have one character swim, while the others walk / jump independently.

Really appreciate any help!

Thanks!

-J

In the definition of ACharacter (the parent class of ThirdPersonCharacter) in Engine/Source/Runtime/Engine/Private/Character.cpp about line 1003 (in branch 4.15 at the moment) it has:

//
// Static variables for networking.
//
static uint8 SavedMovementMode;

So, your result is not surprising. The ACharacter parent class stores the movement mode in a static class variable that would affect any and all instances of the class or any subclasses.

I don’t know much about the networking side of C++ (yet), so I couldn’t say if they really need that variable to be a static class variable in order for it to replicate across the network, but that’s what’s causing the behavior you see.

Thank you for your answer CleanCut! I haven’t looked at C++ in UE4, just learning Blueprint. From your answer it sounds like what I want to do is not possible if I’m using the Character class. I’m very surprised that this is the case, but perhaps there is a reason because of multiplayer.

Do you have any suggestions besides changing source code or using the Pawn class to achieve this?

Thanks again for your hep!

Well, if you are looking for something to be done in blueprints then the only thing I can think of is making your own Pawn subclass blueprint and implementing all of the character functionality by yourself (probably a pretty massive undertaking).

If you are willing to build your engine from source you could experiment with some simple tweaks and see if it works for you. For example, if you aren’t using networking maybe it will “just work” if you remove the static keyword from that line I mentioned so that the movement mode is stored per instance instead of globally in the class.

Thanks for the clarification CleanCut. I think both options are probably too much for me at the moment. I ended up restricting when you can switch characters to prevent those issues.

Thanks for your help!

I filed a bug report because I’m having similar issues: Unreal Engine Issues and Bug Tracker (UE-54905)

UE-54905
Useful information for this bug in this thread.

Thanks! Hopefully this gets addressed in a future release - its quite surprising they didnt anticipate this usecase.