Download

How Can I do this without Tick?

Hello.
This code is working fine, but I want to make it more efficient.
How can I?


void ABasePawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (Recoil != 0 && Controller)
{
Recoil = FMath::FInterpTo(Recoil, 0, DeltaTime, ThirdThing);
Controller->AddPitchInput(Recoil);
}
}

I am assuming it is your weapon recoil. If so put it where you fire the weapon. Then it will only run when you shoot.

Will FInterpTo work in this case?

Could you handle the interpolation with a timer instead of in tick?

This is something that I would handle in tick as well. No matter what, to have a smooth recoil fallback, you’ll have to update it every frame.

I too would keep it in Tick. Otherwise you wouldn’t be able to make it smooth.

I dont understand why you want to avoid tick function? All update calcs like lerp must be there

@HorusWM A big portion of UE users have this notion that tick = bad

Isnt calling if statement every tick bad?

Don’t over-optimize prematurely, and if you are with some performance issue I highly doubt that it is because of that if statement (unless you already profiled and identified that this is the source of your issue).

Tick is only that bad if you have thousands of objects with Tick enabled at the same time.

Only thing you should worry about is memory allocation and functions that do a lot of computation.

Tick has gotten its bad reputation because people abuse it for doing things that don’t belong in Tick.

Ok, thanks for help.