# Adding custom movement component

**URL:** <https://forums.unrealengine.com/t/adding-custom-movement-component/7168>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [July 6, 2014, 5:27pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168 "2014-07-06T17:27:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 6, 2014, 5:27pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/1 "2014-07-06T17:27:17Z")

</div>

I’ve followed Rama’s tutorial here

> **[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 — ue4community.wiki! You will be able to find content from the official...

But now that the component is working, I cant actually move at all. The code below definitely runs and displays stuff on the screen.

```auto

//Tick Comp
void UpXCharMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Component definitely called parent!"));
}

```

I noticed that when my custom movement component is working, my character class no longer has a “Character Movement Component”. I’m pretty sure the is is the cause, but I cant understand why the controller disappears.

I found this in the log but I cant figure out what it means.

```auto

LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.

```

---

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 7, 2014, 6:37am UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/2 "2014-07-07T06:37:39Z")

</div>

It seems others have the same problems. All are on the 4.2 update.

> **[Custom Pawn Movement Component](https://forums.unrealengine.com/questions/23043/custom-pawn-movement-component.html)**
>
> Hello, I have a default pawn that is basically a box component driven by physics and I want to be able to control it’s motion via player inputs. I have successfully implemented the new default pawn, however I don’t fully understand the best way to...

No one has an answer yet. Shooter game works in 4.2 using the same code so I have no idea what is going on

---

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 9, 2014, 11:58pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/3 "2014-07-09T23:58:59Z")

</div>

Could anyone from epic comment on this? Not being able to customise the movement system is driving me crazy. I’m using the 4.2.1 codebase.

Steps to reproduce

Set up a new c++ FPS project  
Add a new code file subclass of CharacterMovementComponent  
Change your projects character.cpp class as follows

```auto

AProjCharacter::AProjCharacter(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<UProjCharacterMovement>(ACharacter::CharacterMovementComponentName))

```

Watch as every call to GetCharacter()-\>CharacterMovement; returns NULL

A good example to breakpoint is APlayerController:BeginPlayingState().

---

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 10, 2014, 11:09pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/4 "2014-07-10T23:09:33Z")

</div>

So I installed the engine from github and started debugging

```auto

AProjectXCharacter::AProjectXCharacter(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)

These two are after InternalConstructor and ConstructObject (respectively) have finished running
![default-post-internal-constructor.PNG|796x860](upload://iby4eZb4d5lYvB10LeLeWSkex4U.png)
![default-post-construct-object.PNG|796x858](upload://gLiiKT2AkH0BcwHdVZXsogOoWaP.png)

The CharacterMovement contains a value in both Autos windows

Then the same again where the only change in the entire code base 

```

AProjectXCharacter::AProjectXCharacter(const class FPostConstructInitializeProperties& PCIP)  
: Super(PCIP.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName)) //: Super(PCIP)

```auto

![934c9c0ee51b2cbdf091cdf4f216505ba9980ff5.png|791x841](upload://l14k3qpCgTCa2AX7468qU5yIe2x.png)
![96596236bc8ee32a83d0b7faa692d53b9e5f49f7.png|795x860](upload://ls37HegWkuea8WNkxj0TrJd7ypF.png)

You can see that the internal constructor correctly created the movement component but it gets lost when returning it all to the SpawnActor function.

I'm now completely at the limit of my knowledge. Is this a bug in the engine or have I done something wrong?
```

---

<div class="post-metadata">

**Author:** ![Blaaguuu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Blaaguuu](https://forums.unrealengine.com/u/Blaaguuu)\
**Post date:** [July 11, 2014, 12:42am UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/5 "2014-07-11T00:42:01Z")

</div>

I’m guessing that you are using a Blueprint as your actual character type? I ran into the same issue with 4.2, where I have a Blueprint of my custom Character, using the default CharacterMovementComponent, and when I updated my Character to use a custom CharacterMovementComponent, the existing Blueprint didn’t work correctly anymore.

My solution was to create a new Blueprint, exactly like the original, after implementing the new CharacterMovementComponent.

I saw some discussion about this elsewhere, and IIRC, someone already submitted a patch to the UnrealEngine project on GitHub to address it - so it shouldn’t be a problem in the next release.

---

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 11, 2014, 12:30pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/6 "2014-07-11T12:30:25Z")

</div>

Thank you for registering and making your first post on this forum a solution to my problem. I love you (in a purely platonic manner).

I’ve updated all the references I’ve found to reflect this knowledge.

---

<div class="post-metadata">

**Author:** ![robert.manuszewski](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@robert.manuszewski](https://forums.unrealengine.com/u/robert.manuszewski)\
**Post date:** [July 14, 2014, 6:31am UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/7 "2014-07-14T06:31:15Z")

</div>

> [@GeekyPayback;90862](#):
>
> ```auto
> 
> LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
> LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
> LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
> 
> ```

This (as well the issue with not being able to set the custom component class) has been fixed [here](https://github.com/EpicGames/UnrealEngine/commit/fab71f76b717a9bafbb0b91831ebb44cd73f0f11).

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [July 14, 2014, 4:22pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/8 "2014-07-14T16:22:57Z")

</div>

> [@robert.manuszewski;95377](#):
>
> This (as well the issue with not being able to set the custom component class) has been fixed [here](https://github.com/EpicGames/UnrealEngine/commit/fab71f76b717a9bafbb0b91831ebb44cd73f0f11).

**Thank you for fixing this Robert!**

Thanks for sharing a solution Starcraft Fan!

Yaaay!

🙂

Rama

---

<div class="post-metadata">

**Author:** ![Rasponien](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rasponien](https://forums.unrealengine.com/u/Rasponien)\
**Post date:** [July 17, 2016, 5:27pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/9 "2016-07-17T17:27:57Z")

</div>

Greetings. I have exactly the same issue with my movement component, but the following comment - “This (as well the issue with not being able to set the custom component class) has been fixed here.” - can’ t help me as the link behind it is not available anymore…

Could you tell me what to do?

---

<div class="post-metadata">

**Author:** ![GeekyPayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GeekyPayback](https://forums.unrealengine.com/u/GeekyPayback)\
**Post date:** [July 17, 2016, 9:22pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/10 "2016-07-17T21:22:13Z")

</div>

The link goes to the relevant line change in github. You need to be signed in and allowed to see the unrealengine source to see it. If you really are falling foul of this bug, the solution is to upgrade to unrealengine 4.3 or higher. Sorry thats probably not the answer you are looking for, but this is a 2 year old thread after all.

You are probably better off starting a new thread, listing out your own error messages and issues (like I did above) as your problem wont be the one discussed above.

---

<div class="post-metadata">

**Author:** ![Mellnik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mellnik](https://forums.unrealengine.com/u/Mellnik)\
**Post date:** [October 1, 2017, 2:42pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/11 "2017-10-01T14:42:01Z")

</div>

I am running in the exact same problem. I was using a custom CharacterMovementComponent. As I no longer require it, I have removed it.  
Now GetCharacterMovement() returns nullptr and I am no longer able to control the character in-game.  
My setup: Custom C++ Character -\> Blueprint Character based on C++.  
Version 4.17.2  
During looking for a solution I noticed that suddenly another completely unrelated Blueprint did no longer compile due to asset references. I never touched the assets.

---

<div class="post-metadata">

**Author:** ![Fluppi393](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fluppi393](https://forums.unrealengine.com/u/Fluppi393)\
**Post date:** [October 1, 2017, 5:16pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/12 "2017-10-01T17:16:47Z")

</div>

> [@Mellnik](#):
>
> I am running in the exact same problem. I was using a custom CharacterMovementComponent. As I no longer require it, I have removed it.  
> Now GetCharacterMovement() returns nullptr and I am no longer able to control the character in-game.  
> My setup: Custom C++ Character -\> Blueprint Character based on C++.  
> Version 4.17.2  
> During looking for a solution I noticed that suddenly another completely unrelated Blueprint did no longer compile due to asset references. I never touched the assets.

Did you try to delete your character blueprint and recreate it as stated above? Blueprints simetimes cause problems when deleting, adding, renaming components etc.

---

<div class="post-metadata">

**Author:** ![Mellnik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mellnik](https://forums.unrealengine.com/u/Mellnik)\
**Post date:** [October 1, 2017, 6:06pm UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/13 "2017-10-01T18:06:24Z")

</div>

Yes, I recreated the entire blueprint. Took me an hour to port everything over.  
It should work more reliable in my opinion. This can be very frustrating.

---

<div class="post-metadata">

**Author:** ![METAVERSEWORLD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@METAVERSEWORLD](https://forums.unrealengine.com/u/METAVERSEWORLD)\
**Post date:** [November 24, 2017, 6:36am UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/14 "2017-11-24T06:36:12Z")

</div>

I have same problem. It occur 100% when I reparent my own ACharacterEx class to ACharacter.  
I’m using UE 4.17.2

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [November 24, 2017, 8:41am UTC](https://forums.unrealengine.com/t/adding-custom-movement-component/7168/15 "2017-11-24T08:41:41Z")

</div>

If you re-created the Blueprint and you have the problem still, then the issue is likely still in the code. Blueprints can hold on to UPROPERTY()'s even if you remove them from the C++ class. It’s fine to add them, but taking them away or renaming objects often means you need to recreate the Blueprint or you might face all kinds of random issues.

The same is true for re-parenting. I would suggest checking the C++ again, then recreating your Blueprint.
