ue4定时器的使用

假设我们有个类AMyActor

1,定时器句柄,可以写成成员,因为我们在删除定时器时用用到

FTimerHandle TestHandel;

2,设置定时器

 GetWorld()->GetTimerManager().SetTimer(TestHandel, this, &AMyActor::Message,0.1f, true);
Message是我们在AMyActor里定义的成员函数

3,删除定时器

GetWorld()->GetTimerManager().ClearTimer(TestHandel);


如果我们想调用回调函数的时候把相关参数传过去可以用下面方法

TimerDel.BindUFunction(this, FName("Message"), para1, para2);
GetWorld()->GetTimerManager().SetTimer(TestHandel,TimerDel, 0.1, false);
para1和para2是我们所要传到Message函数的,当然,Message函数和传过来的参数商量类型应该相吻合
 
原文地址:https://www.cnblogs.com/liuanyin/p/10281980.html