Subclass CharacterMovementComponent breaks existing char blueprint

Hi, I have a derived CharacterMovement class for my characters which has been recently added. This works fine for newly created character blueprints of the custom type, but existing blueprints are missing their CharacterMovement component. Is this a known bug? Is there a way to get the CharacterMovement component back for existing character blueprints? I believe the custom CharacterMovement component to be correct as it works when a new character blueprint is created, its only existing ones that are failing.

I have added the class using the technique described in the wiki
https://wiki.unrealengine.com/Custom_Character_Movement_Component

UE Version: 4.2

I was unable to come up with a fix for this, I therefore copied the details and re-referenced the characters to newly created ones.

Hi b14de,

I was investigating this issue you described, and I saw something similar, but possibly not exactly the same as what you are seeing. I understand that when you play the game you are unable to move, but do you also receive a number error messages in the log when you stop playing?

I looked at the character Blueprint in my game, and it still has a CharacterMovement component. When I mouse over that component, it indicates that it is using my custom movement class. Is the CharacterMovement component completely missing from your character Blueprints?

Hi , thanks for the reply. That’s correct, the movement component is missing for any existing characters using the class that has the newly extended movement component, if I try and play I just get hit with a null pointer break. I’ll try another repo and get back to you :slight_smile:

I had this same problem just now with a subclass of USpringArmComponent. I had to create a new blueprint just as b14de says he did in his answer below.

Hi b14de,

The problem that I ran into seemed to be related to the animations. The CharacterMovement component was still present, but the error log indicated that the animations were not able to transition between states, and I could not move, only rotate the character.

Could you provide some details about your project and characters? What template did you use when you started your project? Are you using an Editor compiled from source code, or are you using the binaries installed by the Launcher? Could you provide the code for your custom CharacterMovementComponent class?

Hi , ah that does sound slightly different to the issues I had. To answer your questions first:

  • The template used was the 3rd person game CPP. All character components are cpp and the character has been extended to include networked weapons using ShooterGame as a ref.

  • The editor is compiled from source (4.2.0 release), unedited.

  • The source for the custom CharacterMovementComponent does nothing currently but will be needed later:

    //CPP
    USHMGCharacterMovement::USHMGCharacterMovement(const class FPostConstructInitializeProperties& PCIP)
    : Super(PCIP)
    {
    }

     //.H
     #pragma once
     #include "SHMGCharacterMovement.generated.h"
     
     UCLASS()
     class USHMGCharacterMovement : public UCharacterMovementComponent
     {
     	GENERATED_UCLASS_BODY()
     };
    

I did a repo today by A: removing the extended SHMGCharacterMovement class from the custom character constructor:

ASHMGCharacter::ASHMGCharacter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{

Starting the editor resulted in the existing characters movementComponent to be removed from its blueprint, as before. I then created a new character (so it would be using the default characterMovement component now) saved, closed and extended the Character class once again to use my customCharacter component.

ASHMGCharacter::ASHMGCharacter(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP.SetDefaultSubobjectClass<USHMGCharacterMovement>(ACharacter::CharacterMovementComponentName))
{

The result was that the previously missing component was back, however the character created when the movementComponent was default (Super(PCIP)) was now missing, which is the original case this post was written for.

If I attempt to run with a missing CharacterMovement component referance in its blueprint I break on line 1086, Character.cpp.

	ReplicatedMovementMode = CharacterMovement->PackNetworkMovementMode();

Hi b14de,

I am still having no luck seeing what you are describing. Just to make sure we are looking at the same thing, is this where you are seeing the CharacterMovement component disappearing?

8525-charmove.png

Are you able to make this happen in a brand new project with an unchanged character class (with the exception of the updated constructor specifying the default character movement component)? If you are able to do so, could you please let me know exactly what steps you took?

Hi , so I went ahead and created a new project from ThirdPersonTemplate Code, extended the movement component as before and the existing character was able to update its movement component to the new extended. However upon removing the extended movement class from the character constructor, the character was unable to update its movement component back to the default movement and the component was removed:

8621-missingmovement01.jpg

I then added a new character blueprint, so this is now using the default 3rd person game code character class with no custom movement component, saved, extended the movement component and recompiled. The result was that the movement component for the new character was once again missing. It seems odd that it should work the 1st time for the character that comes with the 3rd person starter, yet fail once the movement component is removed and added back. If I create a new character at any point, the movement component is created correctly and persist as long as I don’t change its class.

The Log prints the error: "Accessed None: ‘CallFunc_GetMovementComponent_returnValue’ from node Result in blueprint HeroTPP_AnimBlueprint

When making component changes to classes that are blueprinted, more often than not, I have to delete my /Intermediate/Build
directory in my project, then rebuild solution. Then, in the editor, compile again. That usually makes the component change take place.

Hi Anxgotta, thanks for the reply.
I went ahead and tried to fix the problem by doing the steps you describe above: Created a new character, checked it worked, saved, extended the character movement component, deleted Intermediate/build dir, rebuild game solution (which took 25 minutes?!) then compiled in-editor using the Hot-Compile next to the build button. Unfortunately my existing characters Movement Component was missing once again. I did this again, only this time removing the extended character movement component but still to no avail. Did I perhaps miss a step?

Nope, you didn’t. This is definitely odd behavior.

Hi b14de,

The error message you mention is the same one that I was getting when I had set up the custom character movement, which seems to be related to the animations. I still have not been able to get the movement component to disappear, though. I will detail what steps I am taking and if you can tell me anywhere I am doing things differently from you, that would be great.

  1. Run Editor version 4.2.0 compiled from source code by using the compiled UE4.exe file.
  2. Create new project using Third person code template.
  3. Once Visual Studio 2013 has loaded the solution, right-click on the project and build.
  4. Restart Editor and open the project.
  5. Create new character movement component (File → Add code to project).
  6. Close Editor and reload the solution in Visual Studio.
  7. Edit default Character.cpp file to include the new character movement component.
  8. Right-click on the project and build.
  9. Restart Editor and open the project.
  10. Open default character Blueprint (the movement component is present).
  11. Play In Editor (character won’t move).
  12. Stop PIE, error log notification received.
  13. Close Editor.
  14. Remove custom character movement component from default Character.cpp file.
  15. Right-click on the project and build.
  16. Restart Editor and open the project.
  17. Open default character Blueprint (the movement component is still present).

I realize this is probably rather annoying for you, but I need to be able to reliably reproduce exactly what you are seeing in order for us to be able to investigate why it is happening.

Hi , not at all! Thanks for the persistence on this, no doubt it’ll come back to bite me if we don’t get to the bottom of it now.

I went ahead and reproduced your steps listed above exactly, steps 1-17 came out exactly as you described, the char was unable to move yet maintained its new movement component.
I then went ahead and added a new character blueprint (char2) deriving from the 3rd person custom character class without custom movement (step 18), then repeated steps 6 onwards. This resulted in the Char2 blueprint loosing its Movement component at stage 10 after the movement component was extended and reacquiring it at stage 17 after the extended movement component had been removed.
Throughout this, the original character blueprint (MyCharacter) maintained its movement component no matter what class it was using. This would make sense as in my original post I had removed the original character blueprint and was using a new character blueprint.

Hopefully you’ll see the same results?

Hi b14de,

Thank you very much for the clarification. I was able to see the movement component disappear on the new character’s Blueprint. It seems I was not deriving the new character from the existing one. Now that I know how to make it happen, we can try to find out why it is happening.

I really appreciate your patience and help so far.

This sounds like something I fixed in master branch here:

https://github.com/EpicGames/UnrealEngine/commit/fab71f76b717a9bafbb0b91831ebb44cd73f0f11

The fix is really small, so you could try patching the engine yourself and see if that helps.

Just did a repo using the test case outlined by and I can confirm this fixes the original issues, derived component classes are updated and the movement component never gets removed. This issue is still present if a blueprint is created when the movement component already has a derived class and it is removed, going from CustomMover to defaultMover (Steps 13-17) the movement component gets removed from the blueprint, but this is much less of an issue for myself.

Thanks Robert and , really appreciate it.

Hi guys, i think i’m having a similar problem:

Link to my issue
[1]: Using custom movement component removes components from my character's BP - C++ - Epic Developer Community Forums

Could you please take a look at it?

Thanks :slight_smile: