How to change the location of a static mesh with event tick c++?

I want my weapon mesh(static mesh) to kickback every time I press an input. I also need it to come back. Any help is appreciated.

you need to make class time varbale that will track time (lets make it t for here) by adding DeltaTime each tick to it, then make a if which will do something for specific amount of time (here it’s 5 seconds) you can also use FMath::Min to make t flat in to maximum value:

void AMyActor::Tick(float DeltaTime) {

    t += DeltaTime;

    if(t =< 5.0f) {
        SetActorLocation(BaseLocation + FVector(0.0f,0.0f,FMath::Sin(t*10.0f)));



Now inside if put mathematical function of animation with t being timeline axis. For sake of simple example i made simple sinusoid animation which will make actor move up and down. BaseLocation is root point, a actor actual location. You reset animation just by setting t to 0 in other function.

I think in your case most simple way would be use of linera interpolation functions, which will move actor from one delta point ot another over time:

Thanks a lot.