UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category="Components")
USceneComponent* SceneComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UStaticMeshComponent* FloorMesh;
SceneComponent = CreateDefaultSubobject(TEXT("Scene"));
RootComponent = SceneComponent;
FloorMesh = CreateDefaultSubobject(TEXT("FloorMesh"));
FloorMesh->SetupAttachment(SceneComponent);
3.Widget 처럼 빌드 후에 에디터에서 컴퍼넌트 설정한다.
4.Random 과 생성 , InRange , Spawn 관련
const float RandVal = FMath::FRandRange(0.f, 1.f);
FActorSpawnParameters SpawnParameters;
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
const FTransform& SpawnLocation = Lane->GetComponentTransform();
if (UKismetMathLibrary::InRange_FloatFloat(RandVal , SpawnPercent1 , SpawnPercent2 , true , true))
{
AObstacle* obstacle = GetWorld()->SpawnActor<AObstacle>(SmallObstacleClass, SpawnLocation, SpawnParameters);
}
5.GameModeBase 관련 begin play 에서 설정해놓는다.
RunnerGameMode = Cast(UGameplayStatics::GetGameMode(GetWorld()));
6.충돌
FloorTriggerBox->OnComponentBeginOverlap.AddDynamic(this, &AFloorTile::onTriggerBoxOverlap);
onTriggerBoxOverlap 파라미터를 알아내려면
VS 에서 OnComponentBeginOverlap f12 누르면
FComponentBeginOverlapSignature OnComponentBeginOverlap;
가 나온다.
FComponentBeginOverlapSignature f12 누르면
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_SixParams( FComponentBeginOverlapSignature, UPrimitiveComponent, OnComponentBeginOverlap, UPrimitiveComponent, OverlappedComponent, AActor, OtherActor, UPrimitiveComponent*, OtherComp, int32, OtherBodyIndex, bool, bFromSweep, const FHitResult &, SweepResult);
위를 참고 하여 파라미터 설정 ( 뒤에서 부터 , 를 지운다. )
FComponentBeginOverlapSignature, UPrimitiveComponent, OnComponentBeginOverlap 는 삭제
onTriggerBoxOverlap(UPrimitiveComponent OverlappedComponent, AActor OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
cpp 에서 생성
GetWorldTimerManager().SetTimer(DestroyHandle, this, &AFloorTile::DestroyFloorTile, 2.0f , false );
cpp 에서 삭제
if (DestroyHandle.IsValid())
{
GetWorldTimerManager().ClearTimer(DestroyHandle);
}
TARRAY
TArray<AFloorTile*> FloorTiles;
FloorTiles.Empty();
FloorTiles.Add(Tile);
FloorTiles.Remove(Tile); //내부에서 find 해서 지운다.