Override velocity in UCharacterMovementComponent

Hi there, i’m looking how to override the current velocity in a class base on UCharacterMovementComponent? I’m trying to override CalcVelocity() but i’m not sure if it is the function that I need?

I am looking for something like GetMaxSpeed() but for velocity.


void UPlayableCharMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
	Super::CalcVelocity(DeltaTime, Friction, bFluid, BrakingDeceleration);

	const APlayableCharacter* CharOwner = Cast<APlayableCharacter>(PawnOwner);

	if (CharOwner)
	{
		if (CharOwner->GetIsDashing())
		{
			Velocity = CharOwner->GetDashVector();
		}

		if (CharOwner->GetIsGliding())
		{
			Velocity = CharOwner->GetGlideVector();
		}
	}

}

I tried to do that when i’m dashing(during a certain time) or when i’m gliding. The problem is that it’s not replicated over network and the velocity is null. The other problem is that i can put any value that i want on the Z axis, it stay at 0. Am I doing something wrong? Or am i just in the wrong part of the code?

Thanks for your help!

When I change velocity variables on my game to “apply” the settings I’m doing a call to UpdateComponentVelocity(), check if this helps. :smiley:

Thanks man this is working!!
Sans titre.png
I’m also looking where can I update GroundFriction and MaxAcceleration? Maybe in UpdateBasedMovement()?

Good evening!