How to move character as if pressing input

I want my character to move right as if a movement key is being pressed. The below code was created by the engine automatically:

void AMonomythCharacter::MoveRight(float Value)
{
	AddMovementInput(FVector(0.f,-1.f,0.f), Value);
}

I would like this code to constantly work for my character, not when the player presses the input key, how can I achieve this?

thanks in advance.

Hello, Iatsu

In this situation you can override AActor::Tick function for your Character class:

void Tick (float DeltaSeconds) override;

This function is designed to implement custom logic that should be executed every frame. Thus, you can put custom movement logic inside overridden Tick and get the desired result. (The most convenient way would be to create a separate method with DeltaSeconds parameter, place movement-related code there and call from Tick).

Please note that this function is disabled by default so you’ll need to check PrimaryActorTick.bCanEverTick is set to true to enable it.

Hope this helped!

Cheers!

thanks a lot, I actually tried using Tick but I wasn’t aware that it was disabled.