Setting Velocity in a Custom Character Movement Component

Hey everyone,

I’m currently trying to figure out a way to set the velocity in a custom character movement component, I tried overriding the CalcVelocity function and setting the Velocity directly.


void UMyCharacterMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
	Velocity = Acceleration;
}

and it works great… until I run into a wall, or more specifically two walls that are not at a right angle, the collision makes the character shake around because I am forcing the player into the wall, whereas normally when you run into a wall the player will lose Velocity.

Does anyone know of a way to set the velocity directly to a Vector but still allow it to take collision into account?

If you’re doing this a for a character somewhere then you only need to use AddMovementInput(…) which will automatically update the velocity for your character.

If you have to do it this way then you could try to call the super implementation in that function; Super::CalcVelocity(DeltaTime, Friction, bFluid, BrakingDeceleration);