* 전반적인 용어 비교

 

Category Unity UE4
Gameplay Types Component Component
  GameObject Actor, Pawn
  Prefab Blueprint Class
Editor UI Hierarchy Panel World Outliner
  Inspector Details Panel
  Project Browser Content Browser
  Scene View Viewport
Meshes Mesh Static Mesh
  Skinned Mesh Skeletal Mesh
Materials Shader Material, Material Editor
  Material Material Instance
Effects Particle Effect Effect, Particle, Cascade
  Shuriken Cascade
Game UI UI UMG (Unreal Motion Graphics)
Animation Animation Skeletal Animation System
  Mecanim Persona , Animation Blueprint
2D Sprite Editor Paper2D
Programming C# C++
  Script Blueprint
Physics Raycast Line Trace, Shape Trace
  Rigid Body Collision, Physics
Runtime Platforms iOS Player, Web Player Platforms

 

 

* 프로그래밍

 

 

 

* 월드 표현

 

  UnrealEngine Unity
표현 방식 Actor는 RootComponent를 가지고 있으며 이는 SceneComponent의 서브클래스이다. SceneComponent는 계층적인 구조를 이루며 이에 따라 계층적으로 적용되는 위치, 회전, 스케일 정보를 가지고 있다. GameObject는 Transform 컴포넌트를 가지고 있다. 이 Transform는 계층적인 구조를 이룰 수 있으며 위치, 회전, 스케일 정보를 계층적으로 나타낸다.

 

 

 

 

* 객체 생성

 

- 유형별 생성 방법

 

 객체  유형 UnrealEngine Unity 역할
Actor
GameObject
Actor : World 객체를 찾고(일부 객체가 World 객체를 가져올 수 있도록 지원), World 객체의 SpawnActor로 생성하고자 하는 Actor의 클래스를 넘겨서 생성 GameObject : Instantiate함수를 통해 생성 월드에 생성되는 객체들로 대부분의 게임 로직을 담당한다.
UObject
ScriptableObject
UObject : NewObject를 통해 생성 ScriptableObject : ScriptableObject.CreateInstance함수를 통해 생성 월드에 스폰할 필요없거나 Actor처럼 컴포넌트를 포함하는 게임플레이 관련 클래스에 유용하다.

 

// Unity의 GameObject
GameObject NewGO = (GameObject)Instantiate(EnemyPrefab, SpawnPosition, SpawnRotation);
NewGO.name = "MyNewGameObject";

// UE의 Actor
UWorld* World = ExistingActor->GetWorld();
FActorSpawnParameters SpawnParams;
SpawnParams.Template = ExistingActor;
World->SpawnActor<AMyActor>(ExistingActor->GetClass(), SpawnLocation, SpawnRotation, SpawnParams);

 

// Unity의 ScriptableObject
MyScriptableObject NewSO = ScriptableObject.CreateInstance<MyScriptableObject>();

// UE의 UObject
UMyObject* NewObj = NewObject<UMyObject>();

 

 

- 생성 과정

 

Unity UnrealEngine
디폴트 값을 설정하기 위해 선언과 동시에 초기화한다. 각 객체 클래스에는 디폴트 값의 속성들과 컴포넌트들을 클래스 기본 객체(CDO)를 포함하고 있다. 이는 엔진 초기화 시 생성자를 통해서 최초로 생성되며 수정되지 않은 상태로 유지된다.

해당 객체를 생성할때 CDO에서 복사해서 생성한다.

 

Unity / UnrealEngine

 

 

* 캐스팅

 

 

 

* 트리거

 

Unity

public class MyComponent : MonoBehaviour
{
    void Start()
    {
        collider.isTrigger = true;
    }
    void OnTriggerEnter(Collider Other)
    {
        // ...
    }
    void OnTriggerExit(Collider Other)
    {
        // ...
    }
}

 

UnrealEngine

UCLASS()
class AMyActor : public AActor
{
    GENERATED_BODY()

    // My trigger component
    UPROPERTY()
    UPrimitiveComponent* Trigger;

    AMyActor()
    {
        Trigger = CreateDefaultSubobject<USphereComponent>(TEXT("TriggerCollider"));

        // Both colliders need to have this set to true for events to fire
        Trigger.bGenerateOverlapEvents = true;

        // Set the collision mode for the collider
        // This mode will only enable the collider for raycasts, sweeps, and overlaps
        Trigger.SetCollisionEnabled(ECollisionEnabled::QueryOnly);
    }

    virtual void NotifyActorBeginOverlap(AActor* Other) override;

    virtual void NotifyActorEndOverlap(AActor* Other) override;
};

 

 

* 입력

 

Unity

public class MyPlayerController : MonoBehaviour
{
    void Update()
    {
        if (Input.GetButtonDown("Fire"))
        {
            // ...
        }
        float Horiz = Input.GetAxis("Horizontal");
        float Vert = Input.GetAxis("Vertical");
        // ...
    }
}

 

UnrealEngine

UCLASS()
class AMyPlayerController : public APlayerController
{
    GENERATED_BODY()

    void SetupInputComponent()
    {
        Super::SetupInputComponent();

        InputComponent->BindAction("Fire", IE_Pressed, this, &AMyPlayerController::HandleFireInputEvent);
        InputComponent->BindAxis("Horizontal", this, &AMyPlayerController::HandleHorizontalAxisInputEvent);
        InputComponent->BindAxis("Vertical", this, &AMyPlayerController::HandleVerticalAxisInputEvent);
    }

    void HandleFireInputEvent();
    void HandleHorizontalAxisInputEvent(float Value);
    void HandleVerticalAxisInputEvent(float Value);
};

 

 

* 주요 함수

 

- GameObject / Actor 에서 Component 가져오기

 

Unity

MyComponent MyComp = gameObject.GetComponent<MyComponent>();

 

UnrealEngine

UMyComponent* MyComp = MyActor->FindComponentByClass<UMyComponent>();

 

 

- Component 에서 GameObject / Actor 가져오기

 

Unity

MyComponent.gameObject;

 

UnrealEngine

MyComponent->GetOwner();

 

 

- 특정 GameObject / Actor 찾기

 

Unity

// Find GameObject by name
GameObject MyGO = GameObject.Find("MyNamedGameObject");

// Find Objects by type
MyComponent[] Components = Object.FindObjectsOfType(typeof(MyComponent)) as MyComponent[];
foreach (MyComponent Component in Components)
{
        // ...
}

// Find GameObjects by tag
GameObject[] GameObjects = GameObject.FindGameObjectsWithTag("MyTag");
foreach (GameObject GO in GameObjects)
{
        // ...
}

// Find Actor by name (also works on UObjects)
AActor* MyActor = FindObject<AActor>(nullptr, TEXT("MyNamedActor"));

// Find Actors by type (needs a UWorld object)
for (TActorIterator<AMyActor> It(GetWorld()); It; ++It)
{
        AMyActor* MyActor = *It;
        // ...
}

 

UnrealEngine

// Find UObjects by type
for (TObjectIterator<UMyObject> It; It; ++It)
{
    UMyObject* MyObject = *It;
    // ...
}

// Find Actors by tag (also works on ActorComponents, use TObjectIterator instead)
for (TActorIterator<AActor> It(GetWorld()); It; ++It)
{
    AActor* Actor = *It;
    if (Actor->ActorHasTag(FName(TEXT("Mytag"))))
    {
        // ...
    }
}

 

 

+ Recent posts