# How can I modify the character movement component in UE 4.9?

**URL:** <https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, Replication, unreal-engine, UE4, CPP, question\
**Created:** [November 12, 2015, 4:18am UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217 "2015-11-12T04:18:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_642506301](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_642506301](https://forums.unrealengine.com/u/anonymous_user_642506301)\
**Post date:** [November 12, 2015, 4:18am UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/1 "2015-11-12T04:18:39Z")

</div>

Trying to add some custom movement and want to use Approach 4 from:

> **[Networked Movement in the Character Movement Component](https://docs.unrealengine.com/5.1/en-US/understanding-networked-movement-in-the-character-movement-component-for-unreal-engine/)**
>
> Detailed explanation of the Character Movement Component

I can’t figure out how to change the CharacterMovementComponent in my player controller to my derived character movement class “MyCharacterMovementComponent”. I was able to reparent my player controller from Character to “MyCharacter”, but cannot figure out how to modify “MyCharacter” so that “MyCharacterMovementComponent” is the inherited movement component.

The following guides are useful, but seemed to be based around an older version of source code:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

[http://onlogika.com/programming/custom-character-movement-in-custom-character/](http://onlogika.com/programming/custom-character-movement-in-custom-character/)  
[http://error454.com/2015/03/20/ue4/movement/replication/](http://error454.com/2015/03/20/ue4/movement/replication/)

They all reference “const FObjectInitializer& ObjectInitializer)  
: Super(ObjectInitializer)” which I dont have in my derived classes.

One of the guides suggests adding the following within the character class in order to allow the movement component to be changed, but warns that this will affect all other projects on the same computer:

“virtual class UCharacterMovementComponent\* GetCharacterMovement() const;”

Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_642506301](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_642506301](https://forums.unrealengine.com/u/anonymous_user_642506301)\
**Post date:** [March 3, 2016, 3:10am UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/2 "2016-03-03T03:10:30Z")

</div>

Still have the same question after upgrading to 4.10

---

<div class="post-metadata">

**Author:** ![Zexus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zexus](https://forums.unrealengine.com/u/Zexus)\
**Post date:** [July 4, 2016, 10:02am UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/3 "2016-07-04T10:02:04Z")

</div>

Hello, did you find an answer to this ? I’m stuck in it also in 4.11.2

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_88da694e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_88da694e1](https://forums.unrealengine.com/u/anonymous_user_88da694e1)\
**Post date:** [September 20, 2016, 1:17pm UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/4 "2016-09-20T13:17:11Z")

</div>

Same question.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9a89b67](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9a89b67](https://forums.unrealengine.com/u/anonymous_user_b9a89b67)\
**Post date:** [September 20, 2016, 7:34pm UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/5 "2016-09-20T19:34:42Z")

</div>

I do this in 4.12.5,

In my pawn class, I create my custom movement component in my constructor

PawnMovementComponent = CreateDefaultSubobject(TEXT(“PawnMovement”));  
PawnMovementComponent-\>SetUpdatedComponent(CollisionComponent);

and override this…

virtual UPawnMovementComponent\* GetMovementComponent() const override { return PawnMovementComponent; }

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_88da694e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_88da694e1](https://forums.unrealengine.com/u/anonymous_user_88da694e1)\
**Post date:** [September 24, 2016, 2:09am UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/6 "2016-09-24T02:09:53Z")

</div>

I strictly followed [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/Custom_Character_Movement_Component) and worked.  
Remember to modify your character class constructor at header to  
`MyCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());`

---

<div class="post-metadata">

**Author:** ![huulong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@huulong](https://forums.unrealengine.com/u/huulong)\
**Post date:** [December 11, 2016, 9:39pm UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/7 "2016-12-11T21:39:23Z")

</div>

Actually non-character Pawns work quite differently from Characters. They don’t have a default MovementComponent when they are created so you have to add your own, e.g. when subclassing Pawn with a Blueprint. GetMovementComponent()'s base implementation returns the first component of type UPawnMovementComponent. Therefore, as long as you make sure that there is only one MovementComponent on your pawn (which is in general the case), you don’t have to override GetMovementComponent().

I guess what you meant is that Characters are Pawns and therefore could use this method. The problem is that ACharacter still accesses ACharacter::CharacterMovement in its methods, ignoring APawn::GetMovementComponent().

According to the comments in Character.h, CharacterMovement will soon be private and all references to CharacterMovement in the code (except those that set it) should use GetCharacterMovement() instead. If this method becomes virtual and called consistenly in Character.cpp, then overriding it will indeed make the custom CharacterMovement used for motion. However, there would still remain a “hidden” default CharacterMovement on the character (hence gformiga suggesting to replace the class via ObjectInitializer).

---

<div class="post-metadata">

**Author:** ![huulong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@huulong](https://forums.unrealengine.com/u/huulong)\
**Post date:** [December 11, 2016, 10:03pm UTC](https://forums.unrealengine.com/t/how-can-i-modify-the-character-movement-component-in-ue-4-9/338217/8 "2016-12-11T22:03:49Z")

</div>

Cool, worked for me on Unreal 4.13. At first I couldn’t believe you could actually replace a class just like that, but the doc clearly states it uses the static FNames to identify and replace default classes.

> **[CharacterMovementComponentName](https://docs.unrealengine.com/5.2/en-US/API/Runtime/Engine/GameFramework/ACharacter/CharacterMovementComponentName/)**
>
> Name of the CharacterMovement component.

Final code:

**MyCharacter.h**

```
#include ...

class AMyCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	AMyCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

    // ...
}

```

**MyCharacter.cpp**

```
#include ...
#include "MyCharacterMovementComponent.h"

AMyCharacter::AMyCharacter(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))
{
    // ...
}

```
