I am trying to destroy an actor after a delay in C++. I need the other Actor to be passed to the DestroyOther method.
GetWorldTimerManager().SetTimer(DestroyDelayHandle, this, &ATileShooterProjectProjectile::DestroyOther, 3.0f, false);
However it is not possible to use parameters in a delegate method (Source: Using SetTimer() on a Function with Parameters - UE4 AnswerHub).
To try to solve this I created an instance pointer called HitActor.
(inside H file)
/Other actor hit by the projectile/
(inside method with Timer)
HitActor = OtherActor;
Inside the DestroyOther method I try to destroy this HitActor.
However this does not work, I think OtherActor goes out of scope because of the timer.
So how would I make a copy of the other actor, The engine does not seem to allow me to do HitActor = *OtherActor when HitActor is a normal object instead of a pointer. (does not allow me to use = operator)
Is there another alternative to solve this issue?