![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/75384587c1466cd11cdf0e0b539fae26.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9e8c03189b5e5ce3b63a1ee1d88d8c8d.png)
Main入口
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/64ee3e4d67f409f3e07665508cc9709e.png#pic_center)
定时器
FTimerHandle MyTimer;
void APickupSpawner::SpawnUpActor()
{
UWorld* TheWorld = GetWorld();
if (TheWorld != nullptr) {
CurrentPickUp=TheWorld->SpawnActor<APickup>(APickup::StaticClass(), GetTransform());
CurrentPickUp->OnPickupEvent.BindUObject(this, &APickupSpawner::CollectActor);
}
}
void APickupSpawner::CollectActor()
{
GetWorld()->GetTimerManager().SetTimer(MyTimer, this, &APickupSpawner::SpawnUpActor, 10, false);
CurrentPickUp->OnPickupEvent.Unbind();
CurrentPickUp->Destroy();
}
键盘映射
#include "GameFramework/PlayerInput.h"
FInputAxisKeyMapping backKey( "Back", EKeys::S, 1.f );
FInputActionKeyMapping jump("Jump", EKeys::SpaceBar, 0, 0, 0, 0);
GetWorld()->GetFirstPlayerController()->PlayerInput
->AddAxisMapping( backKey );
PlayerInputComponent->BindAxis("Back", this, &AWarrior::Back);
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &AWarrior::Jump
);