Movement Component

Taegang Yun·2024년 6월 11일
0

Unreal

목록 보기
10/11

언리얼에서 제공하는 무브먼트 컴포넌트

FloatingPawnMovement

중력의 영향을 받지 않는 액터의 움직임을 제공. 입력에 따라 자유롭게 움직임 가능.

RotatingMovement

지정한 속도로 액터를 회전시킴.

InterpMovement

지정한 위치로 액터를 이동시킴.

ProjectileMovement

액터에 중력 영향을 주어서 탄도학적인 움직임을 제공. 총알, 미사일 등

CharacterMovementComponent

캐릭터 전용 움직임 컴포넌트. 걷기 뿐만 아니라 수영, 쪼그리기와 같이 다양한 움직임 가능.

// STorch.h

class URotatingMovementComponent;

...
class STUDYPROJECT_API ASTorch : public AActor
{
    ...

private:
    ...

    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "ASTorch", meta = (AllowPrivateAccess))
    TObjectPtr<URotatingMovementComponent> RotatingMovementComponent;

};
// STorch.cpp

...
#include "GameFramework/RotatingMovementComponent.h"

...

ASTorch::ASTorch()
{
    PrimaryActorTick.bCanEverTick = false;

    ...

    RotatingMovementComponent = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovementComponent"));
}

void ASTorch::BeginPlay()
{
    Super::PostInitializeComponents();

    RotationSpeed = 300.f;
    RotatingMovementComponent->RotationRate = FRotator(0.f, RotationSpeed, 0.f);
}

void ASTorch::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);

    //AddActorWorldRotation(FRotator(0.f, RotationSpeed * DeltaSeconds, 0.f));
}

컴포넌트 상속 구조
씬 컴포넌트는 액터 컴포넌트를 상속 받고 트랜스폼 속성이 추가된 컴포넌트.
스태틱 메시 컴포넌트도 씬 컴포넌트를 상속 받음.
반면에 트랜스폼 속성이 필요 없는 무브먼트 컴포넌트들은 액터 컴포넌트를 상속 받음.
BP_ElectricityPole > Components에 보면 MovementComponent만 따로 있음.

profile
언젠간 전문가가 되겠지

0개의 댓글