How to implement own movement mode

I want create custom movement for climbing on ladder but I propably misunderstood the idea how to do it.

My ClimbingMovementComponent.h

   #include "GameFramework/CharacterMovementComponent.h"
    #include "ClimbingMovementComponent.generated.h"
    enum ECustomMovementMode
    	TESTMOVE_Climbing      UMETA(DisplayName = "Climbing"),
    	TESTMOVE_Walking      UMETA(DisplayName = "Walking")
    class GAME_API UClimbingMovementComponent : public UCharacterMovementComponent
    	UPROPERTY(Category = MovementMode, BlueprintReadOnly)
    	TEnumAsByte<enum ECustomMovementMode> NewCustomMovementMode;
    	virtual void PhysCustom(float deltaTime, int32 Iterations) override;
    	UClimbingMovementComponent(const class FObjectInitializer& ObjectInitializer);
    	void PhysCustomClimb(float deltaTime, int32 Iterations);
    	void PhysCustomWalk(float deltaTime, int32 Iterations);

And ClimbingMovementComponent.cpp

#include "Game.h"
#include "ClimbingMovementComponent.h"

UClimbingMovementComponent::UClimbingMovementComponent(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)

void UClimbingMovementComponent::PhysCustom(float deltaTime, int32 Iterations)
	switch (CustomMovementMode)
	case TESTMOVE_Climbing:
		PhysCustomClimb(deltaTime, Iterations);
	case TESTMOVE_Walking:
		PhysCustomElse(deltaTime, Iterations);

void UClimbingMovementComponent::PhysCustomClimb(float deltaTime, int32 Iterations)
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("Climb"));

void UClimbingMovementComponent::PhysCustomWalk(float deltaTime, int32 Iterations)
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("Walk"));

Also I added this to my character :

APlayerGhost::APlayerGhost(const class FObjectInitializer& ObjectInitializer) : 

And set movement to custom:

GetCharacterMovement()->SetMovementMode(MOVE_Custom, TESTMOVE_Climbing);

Build succeeded but I can’t get it working. What I’m doing wrong ?
Is this a way how to achieve custom movement mode ? Is there any better way then create new class ?

EDIT: My bug was outside this solution. So this aproach is allright.

Looks fine to me, you seem to have it set up in the same way I do. Have you debugged it to find out what is/isn’t happening?

Thanks for your answer.
It seems it works. Is this correct way how to set up new character movement ? Is this correct way how to setup ladder climbing ?
Continuous checking looks like a big performace loss for such simple action like ladder climbing.

As far as I know, yes this is the simplest approach. What do you mean by continuous checking? If you’re referring to running the switch statement every update, it’s completely negligible.

My next idea is place two triggers, at start of ladder and end of ladder. So I could turn on flying mode at the start and turn it off at the end. Thanks to this I would skip calculation of velocity. What is more correct approach ?

Yep it’s a reasonable approach, though it all depends on how you want the movement to work. Triggers are good if you want the ladder climbing automatically activated whenever the character gets to one end of it. If the player should activate climbing directly, you can do a test for proximity/direction of the ladder.

For the movement, in your PhysCustomClimb you can process the player’s input and apply movement to the character along the ladder’s direction vector as appropriate.

Thank you for all your advices. There is a lot possibilities for me to discover :slight_smile: