Do something until key is released


I want to move player up when pressing button until releasing it.

I have bind the actions:

InputComponent->BindAction("Fly", IE_Pressed, this, &AFpsCodeCharacter::Fly);
InputComponent->BindAction("Fly", IE_Released, this, &AFpsCodeCharacter::StopFlying);

and made two methods:

void AFpsCodeCharacter::Fly() {
	bIsFlying = true;

void AFpsCodeCharacter::StopFlying() {
	bIsFlying = false;

And I need something like this:

void AFpsCodeCharacter::Update(float DeltaTime) {
	if (bIsFlying) {
		LaunchCharacter(FVector(0, 0, 1000 * DeltaTime), false, false);

are you looking for Tick()?


virtual void Tick(float DeltaSeconds) override;


void AFpsCodeCharacter::Tick(float DeltaSeconds)
	if (bIsFlying)
		LaunchCharacter(FVector(0, 0, 1000 * DeltaSeconds), false, false);

Thank you :slight_smile:
Can someone confirm that it’s the proper way of doing it?