일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- MAC
- 언리얼 엔진
- DP
- gameplay ability system
- MLFQ
- DSP
- Unreal Engine
- Race condition
- Delegate
- unity
- ret2libc
- Replication
- gas
- 유니티
- 언리얼엔진
- dirty cow
- 게임개발
- animation
- Multiplay
- CTF
- 운영체제
- Rr
- 유스케이스
- 메카님
- stride
- ability task
- boss monster
- 게임 개발
- Security
- photon fusion2
Archives
- Today
- Total
다양한 기록
[ChronoSpace] TActorIterator를 이용한 LabyrinthKey 활성화 (Random Activation of Actor) (ClockworkLabyrinth) 본문
언리얼 엔진/ChronoSpace
[ChronoSpace] TActorIterator를 이용한 LabyrinthKey 활성화 (Random Activation of Actor) (ClockworkLabyrinth)
라구넹 2025. 2. 13. 05:16일단 유니티 SetActive같은게 언리얼 액터에 없다는게 놀랍다
void ACSLabyrinthKeyActivator::SetActorActive(AActor* Actor, bool bActive)
{
Actor->SetActorHiddenInGame(!bActive);
Actor->SetActorEnableCollision(bActive);
//SetActorTickEnabled(bActive);
}
Tick 쓸 거면 주석 해제하고 사용
저 대로 쓰면 액티베이트 조정 됨
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CSLabyrinthKeyActivator.generated.h"
UCLASS()
class CHRONOSPACE_API ACSLabyrinthKeyActivator : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACSLabyrinthKeyActivator();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void SetActorActive(AActor* Actor, bool bActive);
void SetLabyrinthKey();
UPROPERTY()
TArray< TObjectPtr<class ACSLabyrinthKey> > Keys;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "MaxKeyCount")
int32 MaxKeyCount;
};
// Fill out your copyright notice in the Description page of Project Settings.
#include "Actor/CSLabyrinthKeyActivator.h"
#include "EngineUtils.h"
#include "Actor/CSLabyrinthKey.h"
#include "ChronoSpace.h"
// Sets default values
ACSLabyrinthKeyActivator::ACSLabyrinthKeyActivator()
{
bReplicates = true;
MaxKeyCount = 3;
}
// Called when the game starts or when spawned
void ACSLabyrinthKeyActivator::BeginPlay()
{
Super::BeginPlay();
if ( HasAuthority() )
{
SetLabyrinthKey();
}
}
void ACSLabyrinthKeyActivator::SetActorActive(AActor* Actor, bool bActive)
{
Actor->SetActorHiddenInGame(!bActive);
Actor->SetActorEnableCollision(bActive);
//SetActorTickEnabled(bActive);
}
void ACSLabyrinthKeyActivator::SetLabyrinthKey()
{
for (TActorIterator<ACSLabyrinthKey> It(GetWorld()); It; ++It)
{
ACSLabyrinthKey* LabyrinthKey = *It;
if ( LabyrinthKey )
{
SetActorActive(LabyrinthKey, false);
Keys.Emplace(LabyrinthKey);
}
}
int8 length = Keys.Num();
if ( length < MaxKeyCount )
{
return;
}
//UE_LOG(LogCS, Log, TEXT("SetLabyrinthKey : %d"), length);
int32 ActivatedKeysCount = 0;
while ( ActivatedKeysCount < MaxKeyCount )
{
int8 Idx = FMath::RandRange(0, length);
if ( !Keys.IsValidIndex(Idx) || Keys[Idx]->GetActorEnableCollision() )
{
continue;
}
SetActorActive(Keys[Idx], true);
++ActivatedKeysCount;
}
}
활성화 시킬 총량 조절 시 MaxCount 조절하면 된다
단 애초에 개수가 부족하면 return
월드에 배치하고
랜덤으로 오브젝트가 활성화 되는 걸 알 수 있다
'언리얼 엔진 > ChronoSpace' 카테고리의 다른 글
[ChronoSpace] 키 아이템과 상호작용 with Subsystem Singleton (ClockworkLabyrinth) (0) | 2025.02.13 |
---|---|
[ChronoSpace] Map Design - Clockwork Labyrinth 뼈대 (0) | 2025.02.10 |
[ChronoSpace] Preivew Box 로컬 클라이언트만 보이게 하기 (0) | 2025.02.06 |
[ChronoSpace] 크기가 변하는 BoxComponent의 Offset 계산 (0) | 2025.02.06 |
[ChronoSpace] Static Box Bug? (0) | 2025.02.06 |