您的位置:首页 > 产品设计 > UI/UE

ue4-定时器(废弃)

2016-07-30 22:48 531 查看
此文废弃,格式太难看了,重新用markdown整理了 ,请参照这里:http://blog.csdn.net/yangxuan0261/article/details/54744385

定个成员变量,hold住这个定时器
[align=left]                FTimerHandle       mTimer;[/align]
[align=left]
[/align]
[align=left]使用lambda表达式的delegate[/align]

                                 auto rotaInterp = [&]() -> void{

                                                 mTurnToRot = UKismetMathLibrary:: RInterpTo(

                                                                 GetActorRotation()

                                                                , UKismetMathLibrary::FindLookAtRotation (GetActorLocation(), mTurnToLoc)

                                                                , GetWorld()->GetDeltaSeconds ()

                                                                , 10.f);

                                                 if (GetActorRotation ().Equals( mTurnToRot, 1.f))

                                                {

                                                                 this->GetWorldTimerManager ().ClearTimer( mTimer); //清理定时器

                                                                 UE_LOG(SkillLogger, Warning , TEXT("--- AMyChar::FaceToTargetLoc, stop rotate"));

                                                }

                                                 else

                                                {

                                                                 SetActorRotation(mTurnToRot );

                                                }

                                };

                                 GetWorldTimerManager().SetTimer (mTimer, FTimerDelegate::CreateLambda(rotaInterp ), GetWorld()->GetDeltaSeconds (), true); //设置定时器


[align=left]还有各种delegate就自己去发挥了[/align]



[align=left][/align]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: