Skip to content
Snippets Groups Projects
Select Git revision
  • 00f86d0a5be55df91a32e752fbf10692b7b1bb98
  • master default protected
2 results

azure-storage-file.gemspec

Blame
  • This project manages its dependencies using RubyGems. Learn more
    TeleportationComponent.cpp 13.64 KiB
    // Fill out your copyright notice in the Description page of Project Settings.
    
    
    #include "Pawn/Navigation/TeleportationComponent.h"
    
    #include "EnhancedInputComponent.h"
    #include "NavigationSystem.h"
    #include "Engine/LocalPlayer.h"
    #include "GameFramework/PlayerController.h"
    #include "NiagaraFunctionLibrary.h"
    #include "Kismet/GameplayStatics.h"
    #include "NiagaraDataInterfaceArrayFunctionLibrary.h"
    #include "Utility/RWTHVRUtilities.h"
    #include "MotionControllerComponent.h"
    #include "Camera/CameraComponent.h"
    #include "Kismet/KismetMathLibrary.h"
    
    void UTeleportationComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent)
    {
    	Super::SetupPlayerInput(PlayerInputComponent);
    
    	if (!VRPawn || !VRPawn->HasLocalNetOwner())
    	{
    		return;
    	}
    
    	TeleportTraceComponent = UNiagaraFunctionLibrary::SpawnSystemAtLocation(
    		GetWorld(), TeleportTraceSystem, VRPawn->GetActorLocation(), FRotator(0), FVector(1), true, true,
    		ENCPoolMethod::AutoRelease, true);
    
    	// simple way of changing the handedness
    	if (bMoveWithRightHand)
    	{
    		TeleportationHand = VRPawn->RightHand;
    		RotationHand = VRPawn->LeftHand;
    	}
    	else
    	{
    		TeleportationHand = VRPawn->LeftHand;
    		RotationHand = VRPawn->RightHand;
    	}
    
    	UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(PlayerInputComponent);
    	if (!EI)
    	{
    		UE_LOG(Toolkit, Error, TEXT("Cannot cast Input Component to Enhanced Inpu Component in VRPawnMovement"));
    		return;
    	}
    
    	// teleporting
    	EI->BindAction(Teleport, ETriggerEvent::Started, this, &UTeleportationComponent::OnStartTeleportTrace);
    	EI->BindAction(Teleport, ETriggerEvent::Triggered, this, &UTeleportationComponent::UpdateTeleportTrace);
    	EI->BindAction(Teleport, ETriggerEvent::Completed, this, &UTeleportationComponent::OnEndTeleportTrace);
    	EI->BindAction(Teleport, ETriggerEvent::Canceled, this, &UTeleportationComponent::OnEndTeleportTrace);
    
    	EI->BindAction(CancelTeleport,ETriggerEvent::Started, this, &UTeleportationComponent::OnCancelTeleport);
    
    	// turning is defined in MovementComponentBase
    }
    
    void UTeleportationComponent::PlayHapticEffect(UHapticFeedbackEffect_Base* HapticEffect, float Intensity)
    {
    	Intensity = FMath::Clamp(Intensity, 0.f, 1.f);
    	APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
    	PlayerController->PlayHapticEffect(HapticEffect, EControllerHand::Right,Intensity);
    }
    
    void UTeleportationComponent::BeginPlay()
    {
    	Super::BeginPlay();