[UnrealEngine] Actor and Component


액터

  • 레벨에 배치할 수 있는 오브젝트.
  • Tick() 함수를 통해 틱 가능.
  • 게임플레이 코드를 통해 생성 및 소멸 가능.
  • C++에서 AActor는 모든 액터의 베이스 클래스.
  • 위치와 회전, 스케일 같은 트랜스폼 데이터를 직접 저장하지는 않고, 액터의 루트 컴포넌트에 대한 트랜스폼 데이터를 사용.
  • 액터 생성은 SpawnActor()로 할 수 있고, Destroy()로 소멸 가능하다.

액터 종류 예 : StaticMeshActor, CameraActor, PlayerStartActor


상속 계층구조

UObjectBase
UObjectBaseUtility
UObject
AActor
APawn
ACharacter


  • APawn 클래스는 “플레이어 또는 AI가 제어할 수 있는 액터들”의 베이스 클래스입니다.
  • ACharacter 클래스는 APawn을 좀 더 특화시킨. 즉, 좀 더 특징을 구체적으로 만든 느낌. SkeletalMeshComponent (Primitive), CapsuleComponent (Primitive), CharacterMovementComponent (Actor)를 Pawn에 추가.


컴포넌트

액터는 컴포넌트를 담는 컨테이너로 생각할 수 있다.


주요 컴포넌트 타입

  • UActorComponent : 베이스 컴포넌트로 입력(Input) 해석과 같은 개념적 기능에 사용된다. TickComponent() 함수를 사용하여 컴포넌트를 틱 시킬 수 있다.
  • USceneComponent : 트랜스폼이 있는 "액터 컴포넌트". 액터의 위치와 회전, 스케일은 계층구조의 루트에 있는 씬 컴포넌트에서 가져온다. 액터 컴포넌트에 어태치된 다른 액터 컴포넌트는 어태치된 대상 컴포넌트를 기준으로 한 트랜스폼 정보를 가진다.
  • UPrimitiveComponent : 메시나 파티클 시스템 같은 일종의 그래픽 표현이 있는 "씬 컴포넌트". 피직스 및 콜리전 세팅이 있다. 예시로는,
    1. 박스 컴포넌트(Box Component)
    2. 캡슐 컴포넌트(Capsule Component)
    3. 스태틱 메시 컴포넌트(Static Mesh Component)
    4. 스켈레탈 메시 컴포넌트(Skeletal Mesh Component)
      이 있다.


상속 계층구조

UObjectBase
UObjectBaseUtility
UObject
UActorComponent
USceneComponent
UPrimitiveComponent
UMeshComponent
UStaticMeshComponent


TMI Zone

ActorComponent는 TickComponent()를 통해 틱 할 수 있는데, 기본적으로는 Tick하지 않게 설정되어 있음. 그래서 Tick 하려면 생성자에서 PrimaryComponentTick.bCanEverTick 을 true로 세팅하고, 생성자 또는 다른 위치에서 PrimaryComponentTick.SetTickFunctionEnable(true) 을 호출하여 틱을 실행할 수 있다. PrimaryComponentTick.SetTickFunctionEnable(false)로 틱 실행을 멈출 수도 있다.


https://docs.unrealengine.com/5.3/ko/actors-in-unreal-engine/ https://docs.unrealengine.com/5.3/ko/components-in-unreal-engine/

Leave a comment