본문 바로가기

강동새싹언리얼수업/언리얼

VRPawn 따라하기

VRCharacter.h

 

C++로 안되는 이유 VRPawn을 보면 VROrigin이 있다.

C++에서  VROrigin을 만들어 준다.

VRCharacted.h

protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite ,Category = "HMD")
class UCameraComponent* CameraComp;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HMD")
class USceneComponent* VROrigin;

VRCharacter.cpp

#include "Components/SceneComponent.h"

AVRCharacter::AVRCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	VROrigin = CreateDefaultSubobject<USceneComponent>(TEXT("VROrigin"));
	SetRootComponent(VROrigin);

	GetMesh()->SetupAttachment(RootComponent);
	GetArrowComponent()->SetupAttachment(RootComponent);
	GetCapsuleComponent()->SetupAttachment(RootComponent);
	GetCapsuleComponent()->SetCapsuleSize(1.f, 1.f);



	LeftController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftCon"));
	LeftController->MotionSource = FName("Left");
	LeftController->SetupAttachment(RootComponent);
	
	RightController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightCon"));
	RightController->MotionSource = FName("Right");
	RightController->SetupAttachment(RootComponent);

	
	CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("HMD"));
	CameraComp->SetupAttachment(RootComponent);
}