Skip to content
Snippets Groups Projects
Select Git revision
  • f597e32302f8976263a0ea6870872c8756bf9ea7
  • 5.4 default protected
  • 5.5
  • dev/5.5
  • dev/5.4
  • dev/5.3_downgrade
  • feature/experimenttime_hack
  • 5.3 protected
  • _IntenSelect5.3
  • IntenSelect5.3
  • 4.27 protected
  • 4.26 protected
  • 5.0 protected
  • 4.22 protected
  • 4.21 protected
  • UE5.4-2024.1
  • UE5.4-2024.1-rc1
  • UE5.3-2023.1-rc3
  • UE5.3-2023.1-rc2
  • UE5.3-2023.1-rc
20 results

VirtualRealityPawn.cpp

Blame
  • user avatar
    Qurabi authored
    f597e323
    History
    VirtualRealityPawn.cpp 21.33 KiB
    #include "VirtualRealityPawn.h"
    
    #include "Camera/CameraComponent.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 "Components/SphereComponent.h"
    #include "DrawDebugHelpers.h"
    #include "Math/Vector.h"
    #include "VirtualRealityUtilities.h"
    
    #include "GrabbingBehaviorComponent.h"
    #include "Grabable.h"
    #include "Clickable.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"));
    	Head->SetupAttachment(RootComponent);
    	RightHand = CreateDefaultSubobject<USceneComponent>(TEXT("RightHand"));
    	RightHand->SetupAttachment(RootComponent);
    	LeftHand = CreateDefaultSubobject<USceneComponent>(TEXT("LeftHand"));
    	LeftHand->SetupAttachment(RootComponent);
    
    	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)
    {
    	if (RightHand)
    	{
    		HandleMovementInput(Value, RightHand->GetForwardVector());