A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRTeleporter.cpp
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
4#include "Components/StaticMeshComponent.h"
5#include "Components/SplineComponent.h"
6#include "Components/WidgetInteractionComponent.h"
7#include "Kismet/GameplayStatics.h"
8#include "NavigationSystem.h"
10#include "PixoVRCharacter.h"
13#include "Kismet/KismetMathLibrary.h"
14
15#define TELEPORT_DEBUG 0
16
17DEFINE_LOG_CATEGORY(LogPixoVRTeleporter);
18
20 : ArcSplineComponent(nullptr)
21 , ArcEndPoint(nullptr)
22 , TeleportCylinder(nullptr)
23 , Ring(nullptr)
24 , Arrow(nullptr)
25 , ArcSplineMesh(nullptr)
26 , ArcSplineMaterial(nullptr)
27 , MotionController(nullptr)
28 , bIsTeleporterActive(false)
29 , bIsValidTeleportDestination(false)
30 , bDrawTeleportArrow(false)
31 , bDrawArcSpline(true)
32 , bDrawTeleportCylinder(true)
33 , TeleportRotation(FRotator::ZeroRotator)
34 , PadRotation(FRotator::ZeroRotator)
35 , ThumbDeadZone(0.5f)
36 , TeleportLaunchVelocity(1200.0f)
37 , FadeInDuration(0.25f)
38 , FadeOutDuration(0.25f)
39 , TeleportFadeColor(FLinearColor::Black)
40 , NavigationSystem(nullptr)
41{
42 PrimaryActorTick.bCanEverTick = true;
43 PrimaryActorTick.bStartWithTickEnabled = false;
44
45 bReplicates = true;
46 SetReplicateMovement(false);
47 bNetLoadOnClient = false;
48
49 static ConstructorHelpers::FObjectFinder<UStaticMesh> ArcSplineMeshFinder(TEXT("StaticMesh'/PixoCore/Meshes/Controller/BeamMesh.BeamMesh'"));
50 ArcSplineMesh = ArcSplineMeshFinder.Object;
51
52 static ConstructorHelpers::FObjectFinder<UMaterial> ArcSplineMaterialFinder(TEXT("Material'/PixoCore/Materials/Controller/SplineArcMaterial.SplineArcMaterial'"));
53 ArcSplineMaterial = ArcSplineMaterialFinder.Object;
54
55 static ConstructorHelpers::FObjectFinder<UStaticMesh> ArcEndPointMeshFinder(TEXT("StaticMesh'/PixoCore/Meshes/BasicShapes/Sphere.Sphere'"));
56 UStaticMesh* ArcEndPointMesh = ArcEndPointMeshFinder.Object;
57
58 static ConstructorHelpers::FObjectFinder<UMaterial> ArcEndPointMaterialFinder(TEXT("Material'/PixoCore/Materials/Controller/ArcEndpointMaterial.ArcEndpointMaterial'"));
59 UMaterial* ArcEndPointMaterial = ArcEndPointMaterialFinder.Object;
60
61 static ConstructorHelpers::FObjectFinder<UStaticMesh> CylinderMeshFinder(TEXT("StaticMesh'/PixoCore/Meshes/BasicShapes/Cylinder.Cylinder'"));
62 UStaticMesh* CylinderMesh = CylinderMeshFinder.Object;
63
64 static ConstructorHelpers::FObjectFinder<UStaticMesh> CylinderRingMeshFinder(TEXT("StaticMesh'/PixoCore/Meshes/Controller/SM_FatCylinder.SM_FatCylinder'"));
65 UStaticMesh* CylinderRingMesh = CylinderRingMeshFinder.Object;
66
67 static ConstructorHelpers::FObjectFinder<UMaterialInstance> TeleportCylinderMaterialFinder(TEXT("MaterialInstanceConstant'/PixoCore/Materials/Controller/TeleportCylinderPreviewMaterialInstance.TeleportCylinderPreviewMaterialInstance'"));
68 UMaterialInstance* CylinderMaterial = TeleportCylinderMaterialFinder.Object;
69
70 USceneComponent* SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("TeleportSceneComponent"));
71 RootComponent = SceneComponent;
72
73 // Arc Spline.
74 ArcSplineComponent = CreateDefaultSubobject<USplineComponent>(TEXT("ArcSpline"));
75 ArcSplineComponent->SetupAttachment(SceneComponent);
76 ArcSplineComponent->SetWorldLocation(FVector(12.53f, -1.76f, 2.55f));
77
78 // Arc Endpoint.
79 ArcEndPoint = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ArcEndPoint"));
80 ArcEndPoint->SetupAttachment(SceneComponent);
81 ArcEndPoint->SetWorldScale3D(FVector(0.08f, 0.08f, 0.08f));
82 ArcEndPoint->SetStaticMesh(ArcEndPointMesh);
83 ArcEndPoint->SetMaterial(0, ArcEndPointMaterial);
84 ArcEndPoint->SetVisibility(false, true);
85 ArcEndPoint->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
86 ArcEndPoint->SetGenerateOverlapEvents(false);
87 ArcEndPoint->SetAbsolute(true, true, true);
88
89 // Teleport Cylinder.
90 TeleportCylinder = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TeleportCylinder"));
91 TeleportCylinder->SetupAttachment(SceneComponent);
92 TeleportCylinder->SetWorldScale3D(FVector(0.75f, 0.75f, 1.0f));
93 TeleportCylinder->SetStaticMesh(CylinderMesh);
94 TeleportCylinder->SetMaterial(0, CylinderMaterial);
95 TeleportCylinder->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
96 TeleportCylinder->SetGenerateOverlapEvents(false);
97 TeleportCylinder->SetAbsolute(true, true, true);
98
99 // Teleport Cylinder Ring.
100 Ring = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Ring"));
101 Ring->SetupAttachment(TeleportCylinder);
102 Ring->SetRelativeScale3D(FVector(0.5f, 0.5f, 0.15f));
103 Ring->SetStaticMesh(CylinderRingMesh);
104 Ring->SetMaterial(0, ArcEndPointMaterial);
105 Ring->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
106 Ring->SetGenerateOverlapEvents(false);
107
108 // Teleport Cylinder Arrow.
109 static ConstructorHelpers::FObjectFinder<UStaticMesh> CylinderArrowMeshFinder(TEXT("StaticMesh'/PixoCore/Meshes/Controller/BeaconDirection.BeaconDirection'"));
110 UStaticMesh* CylinderArrowMesh = CylinderArrowMeshFinder.Object;
111
112 Arrow = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Arrow"));
113 Arrow->SetupAttachment(SceneComponent);
114 Arrow->SetStaticMesh(CylinderArrowMesh);
115 Arrow->SetMaterial(0, ArcEndPointMaterial);
116 Arrow->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
117 Arrow->SetGenerateOverlapEvents(false);
118 Arrow->SetVisibility(false, true);
119}
120
125
127{
128 Super::BeginPlay();
129
130 TeleportCylinder->SetVisibility(false, true);
131
132 NavigationSystem = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
133}
134
135void APixoVRTeleporter::Tick(float DeltaTime)
136{
137 Super::Tick(DeltaTime);
138
140 {
141 TickTeleporter(DeltaTime);
142 }
143}
144
146{
147 Super::Destroyed();
148
149 ClearArc();
150}
151
153{
154 TArray<FVector> TracePoints;
155
156 // Is the location of the projectile falling onto the ground.
157 FVector TraceLocation;
158
159 // The projects location will be mapped to the Nav Mesh location.
160 FVector NavMeshLocation;
161
162 bIsValidTeleportDestination = TraceTeleportDestination(TracePoints, TraceLocation, NavMeshLocation);
163
165 {
167 }
168
170 {
171 TeleportCylinder->SetVisibility(bIsValidTeleportDestination, true);
172 }
173
176
177 // We prepare the rotation of the teleport cylinder.
178 if(PadRotation != FRotator::ZeroRotator)
179 {
180 // User changed rotation using the otion Controller Pad.
182 }
183 else
184 {
185 // If we don't have any Motion Controller Pad rotation, set pitch and roll to zero.
186 // and use previous Yaw rotation.
187 TeleportRotation.Pitch = 0.0f;
188 TeleportRotation.Roll = 0.0f;
189 }
190
191#if TELEPORT_DEBUG
192 // The following lines can be all deleted. It exists only for debug purpose.
193 FVector DevicePosition = FVector::ZeroVector;
194 FRotator DeviceRotation = FRotator::ZeroRotator;
195 UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceRotation, DevicePosition);
196 DevicePosition.Z = 0.0f;
197 FVector Correction = UKismetMathLibrary::GreaterGreater_VectorRotator(DevicePosition, TeleportRotation);
198
199 FVector HMDPositionInWorldSpace = GetOwner()->GetActorLocation() - DevicePosition;
200 APixoVRCharacter* PixoVRCharacter = Cast<APixoVRCharacter>(GetOwner());
201 HMDPositionInWorldSpace = PixoVRCharacter->GetVRLocation();
202 HMDPositionInWorldSpace.Z = 30.0f;
203 FVector OwnerActorLocation = GetOwner()->GetActorLocation();
204 OwnerActorLocation.Z += 10.0f;
205 UKismetSystemLibrary::DrawDebugLine(this, OwnerActorLocation, TeleportCylinder->GetComponentLocation(), FColor::Red, 0.0f, 2.0f);
206 UKismetSystemLibrary::DrawDebugLine(this, OwnerActorLocation, HMDPositionInWorldSpace, FColor::Green, 0.0f, 2.0f);
207#endif
208}
209
211{
212 MotionController = InMotionController;
213}
214
216{
217 if(InActivate == bIsTeleporterActive)
218 {
219 return;
220 }
221
222 bIsTeleporterActive = InActivate;
223
224 // Enable/Disable ticking for this actor.
225 SetActorTickEnabled(bIsTeleporterActive);
226
227 // Hide/Show the teleport cylinder.
229 {
230 TeleportCylinder->SetVisibility(InActivate, true);
231 }
232
233 // Hide/Show the arc splines.
234 ArcSplineComponent->SetVisibility(InActivate && bDrawArcSpline, true);
235
236 // Handle visibility of the arrow if it is enabled.
237 Arrow->SetVisibility(InActivate && bDrawTeleportArrow, true);
238
239 // The ArchEndPoint is activated inside UpdateArchEndPoint. We deactivate definitely when
240 // InActivate = false.
241 if(!InActivate)
242 {
243 ArcEndPoint->SetVisibility(false, false);
244 ClearArc();
245 }
246}
247
249{
250 for(const auto& SplineMeshComponent : SplineMeshComponents)
251 {
252 SplineMeshComponent->DestroyComponent();
253 }
254 SplineMeshComponents.Empty();
255
256 ArcSplineComponent->ClearSplinePoints(true);
257}
258
259bool APixoVRTeleporter::TraceTeleportDestination(TArray<FVector>& TracePoints, FVector& TraceLocation, FVector& NavMeshLocation)
260{
261 FVector StartPos(FVector::ZeroVector);
262 FVector LaunchVelocity (FVector::ZeroVector);
263
264 GetTeleportationTransform(StartPos, LaunchVelocity);
265 LaunchVelocity *= TeleportLaunchVelocity;
266
267 TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
268 ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_WorldStatic));
269
270 FPredictProjectilePathParams Params;
271 Params.bTraceWithCollision = true;
272 Params.bTraceComplex = false;
273 Params.DrawDebugType = EDrawDebugTrace::None;
274 Params.DrawDebugTime = 0.0f;
275 Params.SimFrequency = 30.0f;
276 Params.OverrideGravityZ = 0.0f;
277 Params.ObjectTypes = ObjectTypes;
278 Params.bTraceWithChannel = false;
279 Params.ProjectileRadius = 0.0f;
280 Params.StartLocation = StartPos;
281 Params.MaxSimTime = 2.0f;
282 Params.LaunchVelocity = LaunchVelocity;
283
284 FPredictProjectilePathResult PredictResult;
285 bool bHit = UGameplayStatics::PredictProjectilePath(this, Params, PredictResult);
286
287 FHitResult HitResult;
288 FVector LastTraceDestination;
289
290 HitResult = PredictResult.HitResult;
291 LastTraceDestination = PredictResult.LastTraceDestination.Location;
292 TracePoints.Empty(PredictResult.PathData.Num());
293
294 for (const FPredictProjectilePathPointData& PathPoint : PredictResult.PathData)
295 {
296 TracePoints.Add(PathPoint.Location);
297 }
298
299 TraceLocation = HitResult.Location;
300
301 bool bProjectPointToNavigation = false;
303 {
304 FVector QueryingExtent (500.0f, 500.0f, 500.0f);
305 FNavLocation NavLocation {};
306
307 bProjectPointToNavigation = NavigationSystem->ProjectPointToNavigation(HitResult.Location, NavLocation, QueryingExtent);
308 NavMeshLocation = NavLocation.Location;
309 }
310
311 bProjectPointToNavigation = (NavMeshLocation != FVector(0.0f, 0.0f, 0.0f)) && (TraceLocation != NavMeshLocation);
312
313 return bHit & bProjectPointToNavigation;
314}
315
316void APixoVRTeleporter::GetTeleportationTransform(FVector& Location, FVector& ForwardVector)
317{
318 Location = RootComponent->GetComponentLocation();
319 ForwardVector = RootComponent->GetForwardVector();
320}
321
322FVector APixoVRTeleporter::GetTeleportDestination(const FVector& OriginalLocation)
323{
324 APixoVRCharacter* PixoVRCharacter = Cast<APixoVRCharacter>(GetOwner());
325 FVector Offset = PixoVRCharacter->VRRootReference->OffsetComponentToWorld.GetLocation() - PixoVRCharacter->GetActorLocation();
326 Offset.Z = 0.0f;
327 return OriginalLocation - Offset;
328}
329
331{
333 {
334 return;
335 }
336
338}
339
340FRotator APixoVRTeleporter::GetRotationFromInput(const FVector2D& Direction)
341{
342 // Rotate input X+Y always point forward relative to the current pawn rotation.
343 FVector A(Direction.X, Direction.Y, 0.0f);
344
345 // We should normalize the vector.
346 A.Normalize();
347
348 // Check whether thumb in near center (ignore rotation overrides).
349 const bool Condition = A.Size() > ThumbDeadZone;
350 if(Condition)
351 {
352 FRotator CharacterRotation = GetOwner()->GetActorRotation();
353 CharacterRotation.Roll = 0.0f;
354 CharacterRotation.Pitch = 0.0f;
355
356 const FVector RotatedVector = CharacterRotation.RotateVector(A);
357 return RotatedVector.Rotation();
358 }
359
360 return FRotator::ZeroRotator;
361}
362
363void APixoVRTeleporter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
364{
365 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
366
367 DOREPLIFETIME(APixoVRTeleporter, MotionController);
368}
369
370void APixoVRTeleporter::UpdateTeleportCylinder(const FVector& NavMeshLocation, bool ValidLocationFound)
371{
372 if(ValidLocationFound)
373 {
374 const auto Start = NavMeshLocation;
375 const auto End = Start + FVector(0.0f, 0.0f, -200.0f);
376 TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
377 ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECC_WorldStatic));
378 const auto TraceComplex = false;
379 const TArray<AActor*> ActorsToIgnore;
380 const auto IgnoreSelf = true;
381 FHitResult HitResult;
382 const float DrawTime = 5.0;
383
384 UKismetSystemLibrary::LineTraceSingleForObjects(this,
385 Start,
386 End,
387 ObjectTypes,
388 TraceComplex,
389 ActorsToIgnore,
390 EDrawDebugTrace::None,
391 HitResult,
392 IgnoreSelf,
393 FLinearColor::Red,
394 FLinearColor::Green,
395 DrawTime);
396
397 FVector NewLocation = FVector::ZeroVector;
398 if(HitResult.bBlockingHit)
399 {
400 NewLocation = HitResult.ImpactPoint;
401 }
402 else
403 {
404 NewLocation = NavMeshLocation;
405 }
406
407 TeleportCylinder->SetWorldLocation(NewLocation, false, nullptr, ETeleportType::TeleportPhysics);
408 }
409 else
410 {
411 // TODO Do we want to do something here if we have no valid location?
412 }
413}
414
415void APixoVRTeleporter::UpdateArcEndpoint(const FVector& NewLocation, bool ValidLocationFound)
416{
417 ArcEndPoint->SetVisibility(ValidLocationFound, true);
418 ArcEndPoint->SetWorldLocation(NewLocation, false, nullptr, ETeleportType::TeleportPhysics);
419}
420
421void APixoVRTeleporter::UpdateArcSpline(TArray<FVector>& SplinePoints, bool ValidLocationFound)
422{
423 ArcSplineComponent->ClearSplinePoints(true);
424
425 if(ValidLocationFound)
426 {
427 for(auto& SplinePoint : SplinePoints)
428 {
429 ArcSplineComponent->AddSplinePoint(SplinePoint, ESplineCoordinateSpace::Local, true);
430 }
431
432 ArcSplineComponent->SetSplinePointType(SplinePoints.Num() - 1, ESplinePointType::CurveClamped, true);
433
434 if(SplineMeshComponents.Num() < ArcSplineComponent->GetNumberOfSplinePoints())
435 {
436 const int32 NumberOfSplinesToAdd = (ArcSplineComponent->GetNumberOfSplinePoints() - 1) - SplineMeshComponents.Num();
437
438 for(int32 Index = 0; Index <= NumberOfSplinesToAdd; Index++)
439 {
440 USplineMeshComponent* SplineMeshComponent = NewObject<USplineMeshComponent>(this);
441
442 SplineMeshComponent->SetMobility(EComponentMobility::Movable);
443 SplineMeshComponent->SetStartPosition(FVector(0.0f, 0.0f, 0.0f), true);
444 SplineMeshComponent->SetStartTangent(FVector(100.0f, 0.0f, 0.0f), true);
445 SplineMeshComponent->SetEndPosition(FVector(100.0f, 0.0f, 0.0f), true);
446 SplineMeshComponent->SetEndTangent(FVector(100.0f, 0.0f, 0.0f), true);
447 SplineMeshComponent->SetSplineUpDir(FVector(0.0f, 0.0f, 1.0f), true);
448 SplineMeshComponent->SetForwardAxis(ESplineMeshAxis::X, true);
449 SplineMeshComponent->SetStartScale(FVector2D(4, 4));
450 SplineMeshComponent->SetEndScale(FVector2D(4, 4));
451 SplineMeshComponent->SetStaticMesh(ArcSplineMesh);
452 SplineMeshComponent->SetMaterial(0, ArcSplineMaterial);
453 SplineMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
454 SplineMeshComponent->SetGenerateOverlapEvents(false);
455
456 FTransform Transform = FTransform(FRotator(0.0f, 0.0f, 0.0f), FVector(0.0f, 0.0f, 0.0f), FVector(1.0f, 1.0f, 1.0f));
457 SplineMeshComponent->SetRelativeTransform(Transform);
458 SplineMeshComponent->RegisterComponent();
459
460 SplineMeshComponents.Add(SplineMeshComponent);
461 }
462 }
463
464 // Update the start/end points of the spline components.
465 for(int32 Index = 0; Index < SplineMeshComponents.Num(); Index++)
466 {
467 USplineMeshComponent* SplineMeshComponent = SplineMeshComponents[Index];
468
469 if(Index < (ArcSplineComponent->GetNumberOfSplinePoints() - 1))
470 {
471 SplineMeshComponent->SetVisibility(true, false);
472
473 const auto StartTangent = ArcSplineComponent->GetTangentAtSplinePoint(Index, ESplineCoordinateSpace::Local);
474 const auto EndTangent = ArcSplineComponent->GetTangentAtSplinePoint(Index + 1, ESplineCoordinateSpace::Local);
475
476 SplineMeshComponent->SetStartAndEnd(SplinePoints[Index], StartTangent, SplinePoints[Index + 1], EndTangent, true);
477 }
478 else
479 {
480 // Unused spline components we better hide.
481 SplineMeshComponent->SetVisibility(false, false);
482 }
483 }
484 }
485 else
486 {
487 // TODO For now we just hide all splines when we don't have a valid teleport location.
488 for(int32 Index = 0; Index < SplineMeshComponents.Num(); Index++)
489 {
490 USplineMeshComponent* SplineMeshComponent = SplineMeshComponents[Index];
491 SplineMeshComponent->SetVisibility(false, false);
492 }
493 }
494}
495
496#if WITH_EDITOR
497void APixoVRTeleporter::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
498{
499 if(PropertyChangedEvent.Property != nullptr)
500 {
501 const FName PropertyName (PropertyChangedEvent.Property->GetFName());
502 if(PropertyName == GET_MEMBER_NAME_CHECKED(APixoVRTeleporter, bDrawTeleportArrow))
503 {
504 Arrow->SetVisibility(bDrawTeleportArrow, false);
505 }
506 }
507
508 Super::PostEditChangeProperty(PropertyChangedEvent);
509}
510#endif
511
512void APixoVRTeleporter::ExecuteTeleportation(UVRBaseCharacterMovementComponent* InMovementComponent, const FTransform& ActorTransform, const FVector& VRLocation, const FRotator& ActorRotation)
513{
514 // If we don't have a valid destination, don't execute teleportation.
516 {
517 return;
518 }
519
520 MovementComponent = InMovementComponent;
521
522 const FVector PivotPoint = VRLocation;
523 const FVector InvPivotPoint = UKismetMathLibrary::InverseTransformLocation(ActorTransform, PivotPoint);
524
525 const FVector LastValidTeleportLocation = TeleportCylinder->GetComponentLocation();
526 const FVector TeleportToLocation = GetTeleportDestination(LastValidTeleportLocation);
527
528 UVRExpansionFunctionLibrary::RotateAroundPivot(FRotator::ZeroRotator, TeleportToLocation, ActorRotation, InvPivotPoint, TimedLocation, TimedRotation, true);
529
530 auto FadeInFinishedEvent = [this]()
531 {
533 };
534
535 EventLogService::NewEvent<UFadeInAndFadeOutEvent>(nullptr, FadeInFinishedEvent, nullptr, FadeInDuration, 0.0f, FadeOutDuration);
536}
DEFINE_LOG_CATEGORY(LogPixoVRTeleporter)
Pixo VR Character This class represents the main character in the Pixo VR game. It extends the AVRCha...
Class for VR teleporter functionality. It allows teleportation using visual indicators.
void TickTeleporter(float DeltaTime)
Tick the Teleporter.
virtual void BeginPlay() override
float FadeInDuration
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
TArray< USplineMeshComponent * > SplineMeshComponents
UMaterial * ArcSplineMaterial
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Teleporter", Meta = (AllowPrivateAcc...
FRotator TeleportRotation
UPROPERTY(BlueprintReadOnly, Category = "PixoVR | Teleporter")
virtual void Tick(float DeltaTime) override
bool bIsTeleporterActive
UPROPERTY(BlueprintReadOnly, Category = "PixoVR | Teleporter")
virtual void Destroyed() override
bool bDrawTeleportCylinder
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
bool bDrawTeleportArrow
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
UStaticMeshComponent * ArcEndPoint
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
UStaticMeshComponent * Arrow
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
float TeleportLaunchVelocity
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
UStaticMeshComponent * TeleportCylinder
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
FRotator GetRotationFromInput(const FVector2D &Direction)
Calculate the FRotator from the pad of a controller.
UStaticMesh * ArcSplineMesh
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Teleporter", Meta = (AllowPrivateAcc...
UStaticMeshComponent * Ring
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
float FadeOutDuration
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
void GetTeleportationTransform(FVector &Location, FVector &ForwardVector)
Get the teleportation transform which includes location and orientation.
FRotator PadRotation
UPROPERTY(BlueprintReadOnly, Category = "PixoVR | Teleporter")
UGripMotionControllerComponent * MotionController
UPROPERTY(Replicated)
virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty > &OutLifetimeProps) const override
UVRBaseCharacterMovementComponent * MovementComponent
void UpdateTeleportCylinder(const FVector &NewLocation, bool ValidLocationFound)
Update the teleport cylinder.
void ExecuteTeleportation(UVRBaseCharacterMovementComponent *MovementComponent, const FTransform &ActorTransform, const FVector &VRLocation, const FRotator &ActorRotation)
Execute the teleportation. It checks if there is a valid teleport destination before executing the te...
void UpdateArcSpline(TArray< FVector > &SplinePoints, bool ValidLocationFound)
Update the arc spline.
bool bIsValidTeleportDestination
UPROPERTY(BlueprintReadOnly, Category = "PixoVR | Teleporter")
FVector GetTeleportDestination(const FVector &OriginalLocation)
Get the teleport destination.
bool bDrawArcSpline
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
void ClearArc()
Clear the arc spline.
USplineComponent * ArcSplineComponent
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
void ActivateTeleporter(bool InActivate)
Activate or deactivate the Teleporter.
bool IsActivated()
Check if the teleporter is activated.
float ThumbDeadZone
UPROPERTY(EditAnywhere, Category = "PixoVR | Teleporter")
bool TraceTeleportDestination(TArray< FVector > &TracePoints, FVector &TraceLocation, FVector &NavMeshLocation)
Traces the teleport destination using projectile path prediction and navigation system....
UNavigationSystemV1 * NavigationSystem
void SetMotionController(UGripMotionControllerComponent *InMotionController)
Set the motion controller that controls this Teleport.
void UpdateMotionControllerRotation(const FVector2D &Direction)
Update the motion controller rotation for pad rotation.
void UpdateArcEndpoint(const FVector &NewLocation, bool ValidLocationFound)
Update the endpoint of the arc spline.
FVector GetVRLocation() const
UFUNCTION(BlueprintPure, Category = "BaseVRCharacter|VRLocations")
UVRRootComponent * VRRootReference
UPROPERTY(Category = VRCharacter, VisibleAnywhere, Transient, BlueprintReadOnly, meta = (AllowPrivate...
Definition VRCharacter.h:38
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
void PerformMoveAction_Teleport(FVector TeleportLocation, FRotator TeleportRotation, EVRMoveActionVelocityRetention VelocityRetention=EVRMoveActionVelocityRetention::VRMOVEACTION_Velocity_None, bool bSkipEncroachmentCheck=false)
UFUNCTION(BlueprintCallable, Category = "VRMovement")
static void RotateAroundPivot(FRotator RotationDelta, FVector OriginalLocation, FRotator OriginalRotation, FVector PivotPoint, FVector &NewLocation, FRotator &NewRotation, bool bUseOriginalYawOnly=true)
UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",...
FTransform OffsetComponentToWorld