I've just started to learn Unreal Engine 4.26.2 while developing an Atari Pong clone.
This is how I have implemented the Paddle's movement (but this implementation doesn't accelerate or has inertia):
// Called to bind functionality to input
void APaddle::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
// Respond every frame to the values of our movement.
InputComponent->BindAxis(TEXT("MovePaddle"), this, &APaddle::Move_ZAxis);
}
void APaddle::Move_ZAxis(float AxisValue)
{
CurrentVelocity.Z = FMath::Clamp(AxisValue, -1.0f, 1.0f) * 100.0f;
}
But I want to do two things:
While the user is pressing the key the paddle movement will accelerate.
When the user release the key the Paddle won't stop immediately; instead, it will slowing down until it stops.
Is there anything done with Physics that I can use here or do I have to implement it by myself?
By the way, I'm not English and I don't know if inertia is the right word here.