Custom character movement component completely breaking character movement

I recently started messing around with character movement, and decided to override some of the default functions so that I can get the result I want, but i’ve encountered a weird issue that i’m unsure is a bug with UE5 or a mistake on my part.

I’m able to select my custom class just fine, and it will work, but after I restart the editor, the details tab for the character movement component settings is completely blank and the character no longer moves at all!
image

Weirder still is that when I go into the blueprint debugger it claims that the character movement class is “Unknown”
image

I’m fairly certain my code at the very least shouldn’t be breaking it in this way, but maybe someone here can spot an issue I missed!

MyCharacterComponent.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "MyCharacterMovementComponent.generated.h"

/**
 * 
 */
UCLASS()
class SPACEFIGHTER_API UMyCharacterMovementComponent : public UCharacterMovementComponent
{
	GENERATED_BODY()

public:
	virtual void CalcVelocity( float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration ) override;
};

MyCharacterComponent.cpp

#include "MyCharacterMovementComponent.h"

// Override the default CalcVelocity to remove a lot of stuff i don't need, both for performance and so that it controls right.
void UMyCharacterMovementComponent::CalcVelocity( float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration )
{
	Velocity = Acceleration.GetSafeNormal() * GetMaxSpeed();
}

Thanks in advance!

1 Like

Resolved!

With some help from someone more experienced with UE we figured out that I needed to make a custom “Character” class as well, and then set the default subclass to my custom “CharacterMovementComponent” class.

for future reference to anyone else who may experience this issue, I ended up changing the constructor for my custom “Character” class. the constructor is now initialized in the header like this:

DefaultCharacter.h

ADefaultCharacter( const FObjectInitializer& ObjectInitializer );

and is defined in the cpp file like this:

DefaultCharacter.cpp

ADefaultCharacter::ADefaultCharacter( const FObjectInitializer& ObjectInitializer )
	: Super( ObjectInitializer.SetDefaultSubobjectClass<UMyCharacterMovementComponent>( ACharacter::CharacterMovementComponentName ) )
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

Although I do still find it odd that the CharacterMovementComponent details window became completely blank, as it ended up making that blueprint completely impossible to work with, due to not even being able to revert to the default class, so it very likely is a bug.

2 Likes

I’m getting this same issue after converting a previously working project from 5.0 → 5.1. The character will not move and the BP debugger is giving me the “Unknown Class” you observed. It’s like the MovementComponent doesn’t get initialized.

The project uses a custom character class that inherits from the default character class. I do not have a custom movement component. Was this discussion you had with the other dev someplace public I can dig through? My project is entirely in BP and relies on the stock movement component, so your solution doesn’t really apply to me.

I have the same problem… but this solution didn’t work for me…
Do you remember doing something else?
Thank you so much!!

I’m also seeing this issue. All I did was alter the max crouch speed and now I can’t move at all. When I restarted the editor I can no longer see anything in the details panel and I get like a billion errors in the message log after I hit play.

i made an account just to reply to this, if youre still having this issue like i was for days, go to class settings at the top, change parent class to something random, then change it back to character.

2 Likes

Yep, this just worked for me! I would think this is a bug then!

Thanks!