Function on time duration

 Unreal

void ATestActor::BeginPlay(){ Super::BeginPlay();

GetWorld()->GetTimerManager().SetTimer(functionDelay, this, &ATestActor::theFunction, delayTime, delayLoop); }

void ATestActor::Tick(float DeltaTime) { Super::Tick(DeltaTime);

if(stopFtimHandlr) GetWorld()->GetTimerManager().ClearAllTimersForObject(this);//GetWorld()->GetTimerManager().ClearTimer(functionDelay); }

void ATestActor::theFunction(){ UE_LOG(LogTemp, Display, TEXT("Function work on Particular time period")); }

Unity

public float delayTime;

public float delayLoopTime;

[SerializeField] bool stopInvoke;

void Start() => InvokeRepeating("theFunction", delayTime, delayLoopTime);

private void Update() => if(stopInvoke) CancelInvoke();

void theFunction() => print("Function work on Particular time period");

Comments

Popular posts from this blog

Play Sound

Open Level

UI & Widgets