Adding custom movement component

I’ve followed Rama’s tutorial here

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



//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.



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.


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

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

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



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().

So I installed the engine from github and started debugging



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)




![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?

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.

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.

This (as well the issue with not being able to set the custom component class) has been fixed here.

Thank you for fixing this Robert!

Thanks for sharing a solution Starcraft Fan!

Yaaay!

:slight_smile:

Rama

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?

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.

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.

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.

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

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.