Skip to content
Snippets Groups Projects
Select Git revision
  • f6adbd27de26a28ad5fe8dda9b1ad32d0b23a7c6
  • dev default
2 results

main.js

Blame
  • VirtualRealityPawn.cpp 17.87 KiB
    #include "VirtualRealityPawn.h"
    
    #include "Camera/CameraComponent.h"
    #include "Cluster/IDisplayClusterClusterManager.h"
    #include "Engine/Engine.h"
    #include "Engine/World.h"
    #include "Game/IDisplayClusterGameManager.h"
    #include "GameFramework/InputSettings.h"
    #include "GameFramework/WorldSettings.h"
    #include "Kismet/GameplayStatics.h"
    #include "DisplayClusterSettings.h"
    #include "IDisplayCluster.h"
    #include "Engine/Engine.h"
    #include "Camera/CameraComponent.h"
    #include "Components/SphereComponent.h"
    #include "DrawDebugHelpers.h" // include draw debug helpers header file
    #include "Math/Vector.h"
    #include "VirtualRealityUtilities.h"
    
    
    AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
    {
    	bUseControllerRotationYaw = true;
    	bUseControllerRotationPitch = true;
    	bUseControllerRotationRoll = true;
    
    	AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events.
    
    	Movement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("Movement"));
    	Movement->UpdatedComponent = RootComponent;
    
    	RotatingMovement = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovement"));
    	RotatingMovement->UpdatedComponent = RootComponent;
    	RotatingMovement->bRotationInLocalSpace = false;
    	RotatingMovement->PivotTranslation = FVector::ZeroVector;
    	RotatingMovement->RotationRate = FRotator::ZeroRotator;
    
    	Head = CreateDefaultSubobject<USceneComponent>(TEXT("Head"));
    	RightHand = CreateDefaultSubobject<USceneComponent>(TEXT("RightHand"));
    	LeftHand = CreateDefaultSubobject<USceneComponent>(TEXT("LeftHand"));
    
    	HmdLeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("HmdLeftMotionController"));
    	HmdLeftMotionController->SetupAttachment(RootComponent);
    	HmdLeftMotionController->SetTrackingSource(EControllerHand::Left);
    	HmdLeftMotionController->SetShowDeviceModel(true);
    	HmdLeftMotionController->SetVisibility(false);
    
    	HmdRightMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("HmdRightMotionController"));
    	HmdRightMotionController->SetupAttachment(RootComponent);
    	HmdRightMotionController->SetTrackingSource(EControllerHand::Right);
    	HmdRightMotionController->SetShowDeviceModel(true);
    	HmdRightMotionController->SetVisibility(false);
    
    	CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider"));
    	CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
    	CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
    	CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);
    	CapsuleColliderComponent->SetupAttachment(CameraComponent);
    	CapsuleColliderComponent->SetCapsuleSize(40.0f, 96.0f);
    }
    
    void AVirtualRealityPawn::OnForward_Implementation(float Value)
    {
    	VRWolkingMode(Value, RightHand->GetForwardVector());
    
    }
    
    void AVirtualRealityPawn::OnRight_Implementation(float Value)
    {
    	VRWolkingMode(Value, RightHand->GetRightVector());