A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRCharacter.cpp
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#include "PixoVRCharacter.h"
11#include "Components/BillboardComponent.h"
12#include "GameFramework/GameModeBase.h"
18#include "Kismet/GameplayStatics.h"
20
21DEFINE_LOG_CATEGORY(LogPixoVRCharacter);
22
24 : DefaultPlayerHeight(165)
25 , bLaserBeamActive(false)
26 , LeftTeleporterSocket(NAME_None)
27 , RightTeleporterSocket(NAME_None)
28 , TeleportControllerLeft(nullptr)
29 , TeleportControllerRight(nullptr)
30 , LeftLaserBeamSocket(NAME_None)
31 , RightLaserBeamSocket(NAME_None)
32 , LaserControllerLeft(nullptr)
33 , LaserControllerRight(nullptr)
34 , bLeftLaserBeamIsActiveOnStart(false)
35 , bRightLaserBeamIsActiveOnStart(false)
36 , WristMenuLoc(nullptr)
37 , ProgressBarClass(APixoVRCircleProgress::StaticClass())
38 , WristMenuSocket(FName("WristMenuSocket"))
39 , WristMenu(nullptr)
40 , MirroredWristMenuScale(FVector(1, -1, -1))
41 , ToolSocket("ToolSocket")
42 , BaseTurnRate(45.0f)
43 , BaseLookUpRate(45.0f)
44 , bDisableToolsInputBindings(false)
45 , Head(nullptr)
46 , Body(nullptr)
47{
48 PrimaryActorTick.bCanEverTick = true;
49
50 bReplicates = true;
51 SetReplicateMovement(true);
52 bNetLoadOnClient = true;
53
54 static ConstructorHelpers::FObjectFinder<UStaticMesh> HeadMeshFinder(
55 TEXT("StaticMesh'/PixoCore/Meshes/SM_PlayerHead.SM_PlayerHead'"));
56 UStaticMesh* HeadMesh = HeadMeshFinder.Object;
57
58 static ConstructorHelpers::FObjectFinder<UMaterialInstance> HeadMeshMaterialFinder(
59 TEXT("MaterialInstanceConstant'/PixoCore/Materials/MI_PlayerHead.MI_PlayerHead'"));
60 UMaterialInstance* HeadMeshMaterial = HeadMeshMaterialFinder.Object;
61
62 static ConstructorHelpers::FObjectFinder<UStaticMesh> BodyMeshFinder(
63 TEXT("StaticMesh'/PixoCore/Meshes/BasicShapes/Cylinder.Cylinder'"));
64 UStaticMesh* BodyMesh = BodyMeshFinder.Object;
65
66 static ConstructorHelpers::FObjectFinder<UMaterial> BodyMeshMaterialFinder(
67 TEXT("Material'/PixoCore/Materials/Body/BasicShapeMaterialTrans.BasicShapeMaterialTrans'"));
68 UMaterial* BodyMeshMaterial = BodyMeshMaterialFinder.Object;
69
70 TeleportControllerClass = APixoVRTeleporter::StaticClass();
71 LaserControllerClass = APixoVRLaser::StaticClass();
72 WristMenuClass = APixoVRWristMenu::StaticClass();
73
74 Head = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("HeadMesh"));
75 Head->SetStaticMesh(HeadMesh);
76 Head->SetMaterial(0, HeadMeshMaterial);
77 Head->SetRelativeLocation(FVector(0.0f, 0.0f, -15.0f));
78 Head->SetRelativeRotation(FRotator(0.0f, -90.0f, 0.0f));
79 Head->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
80 Head->SetupAttachment(VRReplicatedCamera);
81
82 Body = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BodyMesh"));
83 Body->SetStaticMesh(BodyMesh);
84 Body->SetMaterial(0, BodyMeshMaterial);
85 Body->SetRelativeLocation(FVector(-8.0f, 0.0f, -160.0f));
86 Body->SetRelativeScale3D(FVector(0.5f, 0.5f, 0.1f));
87 Body->SetCollisionProfileName(UCollisionProfile::CustomCollisionProfileName);
88 Body->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
89 Body->SetCollisionObjectType(ECollisionChannel::ECC_Pawn);
90 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Overlap);
91 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldDynamic, ECollisionResponse::ECR_Overlap);
92 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
93 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_PhysicsBody, ECollisionResponse::ECR_Overlap);
94 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_Vehicle, ECollisionResponse::ECR_Overlap);
95 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_Destructible, ECollisionResponse::ECR_Overlap);
96 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Overlap);
97 Body->SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Overlap);
98 Body->SetupAttachment(ParentRelativeAttachment);
99
100 bUseControllerRotationPitch = true;
101 bUseControllerRotationYaw = true;
102 bUseControllerRotationRoll = false;
103
104 VRReplicatedCamera->bUsePawnControlRotation = false;
105 VRReplicatedCamera->bLockToHmd = true;
107 VRReplicatedCamera->SetRelativeLocation(FVector(0.0f, 0.0f, DefaultPlayerHeight));
108
109 WristMenuLoc = CreateDefaultSubobject<UBillboardComponent>(TEXT("Wrist Menu PC Location"));
110 WristMenuLoc->SetRelativeScale3D(FVector(.25f, .25f, .25f));
111 WristMenuLoc->SetRelativeLocation(FVector(50.0f, 2.0f, .0f));
112 WristMenuLoc->SetupAttachment(VRReplicatedCamera);
113
114 InputAdapter = NewObject<UPixoVRInputAdapter>();
115 LongHoldComponent = CreateDefaultSubobject<UPixoVRLongHoldComponent>(TEXT("LongHoldComponent"));
116
117 FadeSphere = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FadeSphere"));
118 FadeSphere->SetupAttachment(VRReplicatedCamera);
119 static ConstructorHelpers::FObjectFinder<UStaticMesh> SphereMeshAsset(
120 TEXT("StaticMesh'/Engine/BasicShapes/Sphere.Sphere'"));
121 FadeSphere->SetStaticMesh(SphereMeshAsset.Object);
122 static ConstructorHelpers::FObjectFinder<UMaterial> FadeSphereMaterialAsset(
123 TEXT("Material'/PixoCore/Materials/Controller/M_FadeMaterial.M_FadeMaterial'"));
124 FadeSphere->SetMaterial(0, FadeSphereMaterialAsset.Object);
125 FadeSphere->SetCollisionProfileName(UCollisionProfile::NoCollision_ProfileName);
126 FadeSphere->SetCollisionEnabled(ECollisionEnabled::NoCollision);
127
128 //Causes crashes on PICO
129 //UBlueprintGeneratedClass* DefaultVRHandClass = Cast<UBlueprintGeneratedClass>(StaticLoadClass(UObject::StaticClass(), nullptr,TEXT("/PixoCore/Blueprints/Hands/BP_PixoVRHand.BP_PixoVRHand_C")));
130 //VRHandClass = DefaultVRHandClass;
131}
132
133
135{
136 Super::BeginPlay();
137
138 OnDestroyed.AddDynamic(this, &APixoVRCharacter::PlayerDestroyed);
139
140 if (GetLocalRole() == ROLE_Authority && GetWorld()->GetAuthGameMode()->GetClass()->ImplementsInterface(UPixoCoreInterface::StaticClass()))
141 {
142 HintManager = Cast<UHintManager>(IPixoCoreInterface::Execute_GetManagerRef(GetWorld()->GetAuthGameMode(), UHintManager::StaticClass()));
143 }
144
145 // We will spawn here only on the clients. The server will spawn the tools when this character gets possessed by a new controller.
146 if(!HasAuthority())
147 {
148 SpawnTeleporter(EControllerHand::Left, true);
149 SpawnTeleporter(EControllerHand::Right, true);
150 }
151
152 const auto DeviceName = UHeadMountedDisplayFunctionLibrary::GetHMDDeviceName();
153
154 UE_LOG(LogPixoVRCharacter, Log, TEXT("PixoVRCharacter::BeginPlay DeviceName = %s"), *DeviceName.ToString());
155
156 if (DeviceName == "SteamVR") // VIVE
157 {
158 UHeadMountedDisplayFunctionLibrary::SetTrackingOrigin(EHMDTrackingOrigin::Floor);
159 }
160 else if (DeviceName == "OculusHMD") // Oculus
161 {
162 UHeadMountedDisplayFunctionLibrary::SetTrackingOrigin(EHMDTrackingOrigin::Eye);
163 VRProxyComponent->AddLocalOffset(FVector(0.0f, 0.0f, DefaultPlayerHeight));
164 }
165 else if (DeviceName == "WaveVR") // FOCUS PLUS
166 {
167 UHeadMountedDisplayFunctionLibrary::SetTrackingOrigin(EHMDTrackingOrigin::Eye);
168 }
169 else if (DeviceName == "PICOXRHMD") // PICO NEO
170 {
171 UHeadMountedDisplayFunctionLibrary::SetTrackingOrigin(EHMDTrackingOrigin::Floor);
172 }
173 else // Windows
174 {
175 ActivateFPSMode(true);
176 }
177}
178
179void APixoVRCharacter::Tick(float DeltaTime)
180{
181 Super::Tick(DeltaTime);
182
184 {
186 }
187
189 {
191 }
192
193 if(GetLocalRole() == ROLE_Authority)
194 {
195 // Do Wrist Menu related stuff.
196 if(WristMenu)
197 {
199 {
200 FVector2D PadPosition = FVector2D::ZeroVector;
201 FVector2D Tmp;
202 if (CurrentWristMenuHand == EControllerHand::Left)
203 {
205 }
206 else
207 {
209 }
210 PadPosition = Tmp;
211 WristMenu->UpdateTrackpadPosition(PadPosition);
212 }
213 }
214 }
215}
216
217void APixoVRCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
218{
219 Super::SetupPlayerInputComponent(PlayerInputComponent);
220
221 if (InputsTable)
222 {
224 }
225 else
226 {
227 UE_LOG(LogPixoVRCharacter, Warning, TEXT("PixoVRCharacter::InputsTable not set!"));
228 }
229
230 PlayerInputComponent->BindAxis("MoveForward", this, &APixoVRCharacter::MoveForward);
231 PlayerInputComponent->BindAxis("MoveRight", this, &APixoVRCharacter::MoveRight);
232 PlayerInputComponent->BindAxis("Turn", this, &APixoVRCharacter::TurnAtRate);
233 PlayerInputComponent->BindAxis("LookUp", this, &APixoVRCharacter::LookUpAtRate);
234
235 PlayerInputComponent->BindAction("TeleportLeft", IE_Pressed, this, &APixoVRCharacter::HandleTeleportLeftPressed);
236 PlayerInputComponent->BindAction("TeleportLeft", IE_Released, this, &APixoVRCharacter::HandleTeleportLeftReleased);
237 PlayerInputComponent->BindAction("TeleportRight", IE_Pressed, this, &APixoVRCharacter::HandleTeleportRightPressed);
238 PlayerInputComponent->BindAction("TeleportRight", IE_Released, this, &APixoVRCharacter::HandleTeleportRightReleased);
239
240 PlayerInputComponent->BindAxis("MotionControllerThumbLeft_Y", this, &APixoVRCharacter::HandleTeleportLeftUp);
241 PlayerInputComponent->BindAxis("MotionControllerThumbLeft_X", this, &APixoVRCharacter::HandleTeleportLeftRight);
242 PlayerInputComponent->BindAxis("MotionControllerThumbRight_Y", this, &APixoVRCharacter::HandleTeleportRightUp);
243 PlayerInputComponent->BindAxis("MotionControllerThumbRight_X", this, &APixoVRCharacter::HandleTeleportRightRight);
244
245 PlayerInputComponent->BindAction("LaserBeamLeft", IE_Pressed, this, &APixoVRCharacter::HandleLaserBeamLeftPressed);
246 PlayerInputComponent->BindAction("LaserBeamRight", IE_Pressed, this, &APixoVRCharacter::HandleLaserBeamRightPressed);
247
248 PlayerInputComponent->BindAction("LaserSelectUILeft", IE_Pressed, this, &APixoVRCharacter::HandleLaserSelectLeft);
249 PlayerInputComponent->BindAction("LaserSelectUILeft", IE_Released, this, &APixoVRCharacter::HandleLaserReleaseLeft);
250 PlayerInputComponent->BindAction("LaserSelectUIRight", IE_Pressed, this, &APixoVRCharacter::HandleLaserSelectRight);
251 PlayerInputComponent->BindAction("LaserSelectUIRight", IE_Released, this, &APixoVRCharacter::HandleLaserReleaseRight);
252
253 PlayerInputComponent->BindAction("PCToggleWristMenu", IE_Pressed, this, &APixoVRCharacter::HandleActivateWristMenuPressedLeft);
254 PlayerInputComponent->BindAction("ActivateWristMenu", IE_Pressed, this, &APixoVRCharacter::HandleActivateWristMenuPressed);
255 PlayerInputComponent->BindAction("SelectWristMenuItemLeft", IE_Pressed, this, &APixoVRCharacter::HandleSelectWristMenuItemPressedLeft);
256 PlayerInputComponent->BindAction("SelectWristMenuItemRight", IE_Pressed, this, &APixoVRCharacter::HandleSelectWristMenuItemPressedRight);
257 PlayerInputComponent->BindAction("DoubleTapWristMenu", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuDoubleTap);
258
259 PlayerInputComponent->BindAction("SelectWristMenuItem1", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem1Pressed);
260 PlayerInputComponent->BindAction("SelectWristMenuItem2", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem2Pressed);
261 PlayerInputComponent->BindAction("SelectWristMenuItem3", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem3Pressed);
262 PlayerInputComponent->BindAction("SelectWristMenuItem4", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem4Pressed);
263 PlayerInputComponent->BindAction("SelectWristMenuItem5", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem5Pressed);
264 PlayerInputComponent->BindAction("SelectWristMenuItem6", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem6Pressed);
265 PlayerInputComponent->BindAction("SelectWristMenuItem7", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem7Pressed);
266 PlayerInputComponent->BindAction("SelectWristMenuItem8", IE_Pressed, this, &APixoVRCharacter::HandleWristMenuItem8Pressed);
267
268 PlayerInputComponent->BindAction("GrabLeft", IE_Pressed, this, &APixoVRCharacter::GrabLeftPressed);
269 PlayerInputComponent->BindAction("GrabLeft", IE_Released, this, &APixoVRCharacter::GrabLeftReleased);
270 PlayerInputComponent->BindAction("GrabRight", IE_Pressed, this, &APixoVRCharacter::GrabRightPressed);
271 PlayerInputComponent->BindAction("GrabRight", IE_Released, this, &APixoVRCharacter::GrabRightReleased);
272
273 PlayerInputComponent->BindAction("HintActivated", IE_Pressed, this, &APixoVRCharacter::ActivateHint);
274
275 PlayerInputComponent->BindAction("TurnVRLeft", IE_Pressed, this, &APixoVRCharacter::TurnVRLeft);
276 PlayerInputComponent->BindAction("TurnVRRight", IE_Pressed, this, &APixoVRCharacter::TurnVRRight);
277}
278
279void APixoVRCharacter::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
280{
281 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
282
283 DOREPLIFETIME(APixoVRCharacter, bIsOverWidgetUse);
286 DOREPLIFETIME(APixoVRCharacter, bActivateLeftLaser);
288 DOREPLIFETIME(APixoVRCharacter, WristMenu);
289 DOREPLIFETIME(APixoVRCharacter, bTeleporterEnabled);
293 DOREPLIFETIME(APixoVRCharacter, ProgressBar);
294}
295
296void APixoVRCharacter::PossessedBy(AController* NewController)
297{
298 Super::PossessedBy(NewController);
299
300 // Spawn hands
301 const FAttachmentTransformRules HandTransformRule = FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false);
302 FActorSpawnParameters ActorSpawnParameters = {};
303 ActorSpawnParameters.Owner = this;
304 ActorSpawnParameters.Instigator = this;
305
306 VRHandLeft = GetWorld()->SpawnActor<APixoVRHand>(VRHandClass, ActorSpawnParameters);
307 VRHandLeft->InitPixoVRHands(EControllerHand::Left, this);
308 VRHandLeft->AttachToComponent(VRProxyComponent, HandTransformRule);
309 VRHandLeft->MotionController->AddTickPrerequisiteComponent(GetCharacterMovement());
311
312 VRHandRight = GetWorld()->SpawnActor<APixoVRHand>(VRHandClass, ActorSpawnParameters);
313 VRHandRight->InitPixoVRHands(EControllerHand::Right, this);
314 VRHandRight->AttachToComponent(VRProxyComponent, HandTransformRule);
315 VRHandRight->MotionController->AddTickPrerequisiteComponent(GetCharacterMovement());
317
318 // We will spawn the tools on the server when the character gets possessed by a new controller.
319 SpawnTeleporter(EControllerHand::Left, true);
320 SpawnTeleporter(EControllerHand::Right, true);
321
322 SpawnLaserBeam(EControllerHand::Left, bLeftLaserBeamIsActiveOnStart);
323 SpawnLaserBeam(EControllerHand::Right, bRightLaserBeamIsActiveOnStart);
324
327}
328
330{
331 if(!CanTeleport())
332 {
333 return;
334 }
335
336 ActivateTeleporter(EControllerHand::Left, true);
337}
338
340{
342 {
343 return;
344 }
345
346 ExecuteTeleportation(EControllerHand::Left);
347}
348
350{
351 if(!CanTeleport())
352 {
353 return;
354 }
355
356 ActivateTeleporter(EControllerHand::Right, true);
357}
358
360{
362 {
363 return;
364 }
365
366 ExecuteTeleportation(EControllerHand::Right);
367}
368
370{
371 return !((WristMenu && WristMenu->IsActivated()) || bTeleporterEnabled == false);
372}
373
375{
376 APixoVRTeleporter* TeleportController = nullptr;
377
378 switch(Hand)
379 {
380 case EControllerHand::Left: TeleportController = TeleportControllerLeft; break;
381 case EControllerHand::Right: TeleportController = TeleportControllerRight; break;
382 }
383
384 // Either no TeleportController class was specified, means the user didn't want to use
385 // a Teleporter at all, or we received a wrong Hand enum which should not happen.
386 if(!TeleportController) return;
387
388 // Execute the teleportation.
389 TeleportController->ExecuteTeleportation(VRMovementReference, GetActorTransform(), GetVRLocation(), GetActorRotation());
390 // Disable the Teleporter.
391 ActivateTeleporter(Hand, false);
392}
393
394void APixoVRCharacter::ActivateTeleporter(EControllerHand Hand, bool InActivate)
395{
396 OnTeleportationActivated().Broadcast(Hand, InActivate);
397
398 switch(Hand)
399 {
400 case EControllerHand::Left:
401 {
403 {
405 }
406 }
407 break;
408 case EControllerHand::Right:
409 {
411 {
413 }
414 }
415 break;
416 default:
417 break;
418 }
419
420 NotifyActivateTeleporter(Hand, InActivate);
421}
422
423void APixoVRCharacter::SpawnTeleporter(EControllerHand Hand, bool InActivate)
424{
425 const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, false);
426 FActorSpawnParameters ActorSpawnParameters = {};
427 ActorSpawnParameters.Owner = this;
428 ActorSpawnParameters.Instigator = this;
429
430 switch (Hand)
431 {
432 case EControllerHand::Left:
433 {
435 {
436 TeleportControllerLeft = GetWorld()->SpawnActor<APixoVRTeleporter>(TeleportControllerClass, ActorSpawnParameters);
438
440 {
441 if (VRHandLeft->HandMesh)
442 {
443 TeleportControllerLeft->AttachToComponent(VRHandLeft->HandMesh, AttachmentTransformRules, LeftTeleporterSocket);
444 }
445 }
446 }
447 }
448 break;
449 case EControllerHand::Right:
450 {
452 {
453 TeleportControllerRight = GetWorld()->SpawnActor<APixoVRTeleporter>(TeleportControllerClass, ActorSpawnParameters);
455
457 {
458 if (VRHandLeft->HandMesh)
459 {
460 TeleportControllerRight->AttachToComponent(VRHandRight->HandMesh, AttachmentTransformRules, RightTeleporterSocket);
461 }
462 }
463 }
464 }
465 break;
466 default: break;
467 }
468}
469
470void APixoVRCharacter::MulticastActivateTeleporter_Implementation(EControllerHand Hand, bool InActivate)
471{
472 if(!IsLocallyControlled())
473 {
474 OnTeleportationActivated().Broadcast(Hand, InActivate);
475 switch (Hand)
476 {
477 case EControllerHand::Left:
478 {
480 {
482 }
483 }
484 break;
485 case EControllerHand::Right:
486 {
488 {
490 }
491 }
492 break;
493 default:
494 break;
495 }
496 }
497}
498
499void APixoVRCharacter::NotifyActivateTeleporter_Implementation(EControllerHand Hand, bool InActivate)
500{
501 MulticastActivateTeleporter(Hand, InActivate);
502}
503
504bool APixoVRCharacter::NotifyActivateTeleporter_Validate(EControllerHand Hand, bool InActivate)
505{
506 return true;
507}
508
510{
511 // Are we going to use the Laser-beam at all?
513 {
514 // No, just don't do anything.
515 return;
516 }
517
519 {
520 return;
521 }
522
524 {
525 bLaserBeamActive = true;
526 ActivateLaserBeam(EControllerHand::Right, false);
527
528 if (VRHandRight->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
529 {
530 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandRight->HandMesh->GetAnimInstance(), EPixoVRGripState::Open);
531 }
532 }
533 else
534 {
536 }
537
538 ActivateLaserBeam(EControllerHand::Left, bLaserBeamActive);
539
540 if (VRHandLeft->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
541 {
543 {
544 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandLeft->HandMesh->GetAnimInstance(), EPixoVRGripState::HoldLaserPointer);
545 }
546 else
547 {
548 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandLeft->HandMesh->GetAnimInstance(), EPixoVRGripState::Open);
549 }
550 }
551}
552
554{
555 // Are we going to use the Laser-beam at all?
557 {
558 // No, just don't do anything.
559 return;
560 }
561
563 {
564 return;
565 }
566
568 {
569 bLaserBeamActive = true;
570 ActivateLaserBeam(EControllerHand::Left, false);
571
572 if (VRHandLeft->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
573 {
574 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandLeft->HandMesh->GetAnimInstance(),
576 }
577 }
578 else
579 {
581 }
582
583 ActivateLaserBeam(EControllerHand::Right, bLaserBeamActive);
584
585 if (VRHandRight->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
586 {
588 {
589 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandRight->HandMesh->GetAnimInstance(), EPixoVRGripState::HoldLaserPointer);
590 }
591 else
592 {
593 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandRight->HandMesh->GetAnimInstance(), EPixoVRGripState::Open);
594 }
595 }
596}
597
598void APixoVRCharacter::IsLaserActivated(bool& IsActivated, EControllerHand& Hand)
599{
600 IsActivated = bLaserBeamActive;
601 Hand = bActivateLeftLaser ? EControllerHand::Left : EControllerHand::Right;
602}
603
604void APixoVRCharacter::IsOverWidgetUse_Implementation(EControllerHand Hand, bool InPressed)
605{
606 PerformIsOverWidgetUse(Hand, InPressed);
607}
608
609void APixoVRCharacter::PerformIsOverWidgetUse_Implementation(EControllerHand Hand, bool InPressed)
610{
611 bIsOverWidgetUse = false;
612
613 switch(Hand)
614 {
615 case EControllerHand::Left:
616 {
618 {
620 }
621 }
622 break;
623 case EControllerHand::Right:
624 {
626 {
628 }
629 }
630 break;
631 default: break;
632 }
633}
634
635bool APixoVRCharacter::IsOverWidgetUse_Validate(EControllerHand Hand, bool InPressed)
636{
637 return true;
638}
639
640void APixoVRCharacter::SpawnLaserBeam(EControllerHand Hand, bool InActivate)
641{
642 const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true);
643 FActorSpawnParameters ActorSpawnParameters = {};
644 ActorSpawnParameters.Owner = this;
645 ActorSpawnParameters.Instigator = this;
646
647 switch(Hand)
648 {
649 case EControllerHand::Left:
650 {
652 {
653 LaserControllerLeft = GetWorld()->SpawnActor<APixoVRLaser>(LaserControllerClass, ActorSpawnParameters);
654 LaserControllerLeft->SetHandType(EControllerHand::Left, IsLocallyControlled());
655 LaserControllerLeft->AttachToComponent(VRHandLeft->HandMesh, AttachmentTransformRules, LeftLaserBeamSocket);
656 LaserControllerLeft->WidgetInteraction->PointerIndex = 0;
657
658 if(InActivate)
659 {
661 }
662 }
663 }
664 break;
665 case EControllerHand::Right:
666 {
668 {
669 LaserControllerRight = GetWorld()->SpawnActor<APixoVRLaser>(LaserControllerClass, ActorSpawnParameters);
670 LaserControllerRight->SetHandType(EControllerHand::Right, IsLocallyControlled());
671 LaserControllerRight->AttachToComponent(VRHandRight->HandMesh, AttachmentTransformRules, RightLaserBeamSocket);
672 LaserControllerRight->WidgetInteraction->PointerIndex = 1;
673
674 if(InActivate)
675 {
677 }
678 }
679 }
680 break;
681 default: break;
682 }
683}
684
686{
688 {
689 IsOverWidgetUse(EControllerHand::Left, true);
690
691 HandleLaserSelectEvent(EControllerHand::Left, true);
692 }
693}
694
696{
698 {
699 IsOverWidgetUse(EControllerHand::Left, false);
700
701 HandleLaserSelectEvent(EControllerHand::Left, false);
702 }
703}
704
706{
708 {
709 IsOverWidgetUse(EControllerHand::Right, true);
710
711 HandleLaserSelectEvent(EControllerHand::Right, true);
712 }
713}
714
716{
718 {
719 IsOverWidgetUse(EControllerHand::Right, false);
720
721 HandleLaserSelectEvent(EControllerHand::Right, false);
722 }
723}
724
725void APixoVRCharacter::HandleLaserSelectEvent_Implementation(EControllerHand Hand, bool Pressed)
726{
727 MultiHandleLaserSelectEvent(Hand, Pressed);
728}
729
730void APixoVRCharacter::MultiHandleLaserSelectEvent_Implementation(EControllerHand Hand, bool Pressed)
731{
732 HandleLaserSelect(Hand, Pressed);
733}
734
735void APixoVRCharacter::HandleLaserSelect(EControllerHand Hand, bool Pressed)
736{
737 switch (Hand)
738 {
739 case EControllerHand::Left:
740 {
742 }
743 break;
744 case EControllerHand::Right:
745 {
747 }
748 break;
749 default:
750 break;
751 }
752}
753
754void APixoVRCharacter::ActivateLaserBeam_Implementation(EControllerHand Hand, bool InActivate)
755{
756 switch (Hand)
757 {
758 case EControllerHand::Left:
759 {
760 VRHandLeft->ToggleLaser(InActivate);
761
762 bActivateLeftLaser = InActivate;
764 }
765 break;
766 case EControllerHand::Right:
767 {
768 VRHandRight->ToggleLaser(InActivate);
769
770 bActivateRightLaser = InActivate;
772 }
773 break;
774 default:
775 break;
776 }
777
779}
780
781bool APixoVRCharacter::ActivateLaserBeam_Validate(EControllerHand Hand, bool InActivate)
782{
783 return true;
784}
785
786void APixoVRCharacter::ActivateFPSMode_Implementation(bool Enable)
787{
788 bFPSMode = Enable;
789
790 if(bFPSMode)
791 {
792 VRHandLeft->AttachToComponent(VRReplicatedCamera, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false));
793 VRHandLeft->SetActorRelativeLocation(FVector(62.0f, -28.0f, -15.0f));
794
795 VRHandRight->AttachToComponent(VRReplicatedCamera, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, false));
796 VRHandRight->SetActorRelativeLocation(FVector(62.0f, 31.0f, -15.0f));
797
798 bUseControllerRotationPitch = false;
799
800 const auto MovementComponent = Cast<UVRCharacterMovementComponent>(GetMovementComponent());
801 MovementComponent->bUseClientControlRotation = true;
802 MovementComponent->bAllowMovementMerging = true;
803
804 VRReplicatedCamera->bUsePawnControlRotation = true;
805 VRReplicatedCamera->bLockToHmd = false;
807 }
808}
809
811{
812 AddActorWorldRotationVR(FRotator(0.0f, -DeflectionAngle, 0.0f));
813}
814
816{
817 AddActorWorldRotationVR(FRotator(0.0f, DeflectionAngle, 0.0f));
818}
819
821{
822 AddMovementInput(GetVRForwardVector(), Value);
823}
824
826{
827 AddMovementInput(GetVRRightVector(), Value);
828}
829
831{
832 AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
833}
834
836{
837 AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
838}
839
841{
842 OnHandGrabAction.Broadcast(true, true);
843
844 if (HoldToolRight)
845 {
846 return;
847 }
848
850
852 {
853 bLaserBeamActive = false;
854 ActivateLaserBeam(EControllerHand::Right, false);
855 }
857 {
858 return;
859 }
860
861 if (VRHandRight->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
862 {
864
865 if (VRHandRight->HandHoldingObject != nullptr)
866 {
867 if (VRHandRight->HandHoldingObject->GetClass()->ImplementsInterface(UGripResponseAnimationInterface::StaticClass()))
868 {
869 if (IGripResponseAnimationInterface::Execute_IsUsingCustomGripAnimation(VRHandRight->HandHoldingObject))
870 {
871 GripAnimation = IGripResponseAnimationInterface::Execute_GetObjectGripAnimation(VRHandRight->HandHoldingObject);
872 }
873 else
874 {
875 GripAnimation = EPixoVRGripState::AdvanceGrab;
876 }
877 }
878 else
879 {
880 GripAnimation = EPixoVRGripState::AdvanceGrab;
881 }
882 }
883 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandRight->HandMesh->GetAnimInstance(), GripAnimation);
884 }
885}
886
888{
889 OnHandGrabAction.Broadcast(true, false);
890
891 if (HoldToolLeft)
892 {
893 return;
894 }
895
897
899 {
900 bLaserBeamActive = false;
901 ActivateLaserBeam(EControllerHand::Left, false);
902 }
904 {
905 return;
906 }
907
908 if (VRHandLeft->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
909 {
911
912 if (VRHandLeft->HandHoldingObject != nullptr)
913 {
914 if (VRHandLeft->HandHoldingObject->GetClass()->ImplementsInterface(UGripResponseAnimationInterface::StaticClass()))
915 {
916 if (IGripResponseAnimationInterface::Execute_IsUsingCustomGripAnimation(VRHandLeft->HandHoldingObject))
917 {
918 GripAnimation = IGripResponseAnimationInterface::Execute_GetObjectGripAnimation(VRHandLeft->HandHoldingObject);
919 }
920 else
921 {
922 GripAnimation = EPixoVRGripState::AdvanceGrab;
923 }
924 }
925 else
926 {
927 GripAnimation = EPixoVRGripState::AdvanceGrab;
928 }
929 }
930 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandLeft->HandMesh->GetAnimInstance(), GripAnimation);
931 }
932}
933
935{
936 OnHandGrabAction.Broadcast(false, true);
937
939 {
941 IPixoVRStoryObject::Execute_DenyDropping(VRHandRight->HandHoldingObject))
942 {
943 return;
944 }
946 IPixoVRStoryObject::Execute_HoldItemByClick(VRHandRight->HandHoldingObject) &&
948 {
949 HoldToolRight = true;
950 return;
951 }
952 }
953
955 {
956 return;
957 }
958
959 if (HoldToolRight)
960 {
961 HoldToolRight = false;
962 }
963
965
966 if (VRHandRight->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(
967 UHandAnimationInterface::StaticClass()))
968 {
969 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandRight->HandMesh->GetAnimInstance(),
971 }
972}
973
975{
976 OnHandGrabAction.Broadcast(false, false);
977
979 {
980 if (VRHandLeft->HandHoldingObject->Implements<UPixoVRStoryObject>() && IPixoVRStoryObject::Execute_DenyDropping(VRHandLeft->HandHoldingObject))
981 {
982 return;
983 }
984 if (VRHandLeft->HandHoldingObject->Implements<UPixoVRStoryObject>() && IPixoVRStoryObject::Execute_HoldItemByClick(VRHandLeft->HandHoldingObject) && !HoldToolLeft)
985 {
986 HoldToolLeft = true;
987 return;
988 }
989 }
990
992 {
993 return;
994 }
995
996 if (HoldToolLeft)
997 {
998 HoldToolLeft = false;
999 }
1000
1002
1003 if(VRHandLeft->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
1004 {
1005 IHandAnimationInterface::Execute_SetAnimationGripState(VRHandLeft->HandMesh->GetAnimInstance(),EPixoVRGripState::Open);
1006 }
1007}
1008
1009AActor* APixoVRCharacter::SpawnActorInHand(TSubclassOf<AActor> ActorClass, bool RightHand)
1010{
1011 APixoVRHand* HandRef = RightHand ? VRHandRight : VRHandLeft;
1012 if (HandRef->HandHoldingObject)
1013 {
1014 UE_LOG(LogTemp, Error, TEXT("APixoVRCharacter - Can't spawn object in the hand"));
1015 return nullptr;
1016 }
1017
1018 AActor* SpawnedActor = GetWorld()->SpawnActor(ActorClass);
1019 APixoVRLaser* LaserRef = RightHand ? LaserControllerRight : LaserControllerLeft;
1020 EControllerHand ActiveHand = RightHand ? EControllerHand::Right : EControllerHand::Left;
1021
1022 HandRef->ManuallyPutActorToHand(SpawnedActor);
1023
1024 if(LaserRef->bIsLaserBeamActive)
1025 {
1026 bLaserBeamActive = false;
1027 ActivateLaserBeam(ActiveHand, false);
1028 }
1029
1030 auto ChangeAnimation = [=]()
1031 {
1032 if (HandRef->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
1033 {
1035
1036 if (SpawnedActor != nullptr)
1037 {
1038 if (SpawnedActor->GetClass()->ImplementsInterface(UGripResponseAnimationInterface::StaticClass()))
1039 {
1040 if (IGripResponseAnimationInterface::Execute_IsUsingCustomGripAnimation(SpawnedActor))
1041 {
1042 GripAnimation = IGripResponseAnimationInterface::Execute_GetObjectGripAnimation(SpawnedActor);
1043 }
1044 else
1045 {
1046 GripAnimation = EPixoVRGripState::AdvanceGrab;
1047 }
1048 }
1049 else
1050 {
1051 GripAnimation = EPixoVRGripState::AdvanceGrab;
1052 }
1053 }
1054 IHandAnimationInterface::Execute_SetAnimationGripState(HandRef->HandMesh->GetAnimInstance(), GripAnimation);
1055 }
1056 };
1057 FTimerDelegate TimerDelegate;
1058 TimerDelegate.BindLambda(ChangeAnimation);
1059 GetWorldTimerManager().SetTimerForNextTick(TimerDelegate);
1060 return SpawnedActor;
1061}
1062
1064{
1066 {
1068 }
1070 {
1072 }
1073}
1074
1076{
1077 APixoVRHand* HandToReset = RightHand ? VRHandRight : VRHandLeft;
1078 RightHand ? HoldToolRight = false : HoldToolLeft = false;
1079
1080 if (HandToReset->HandHoldingObject)
1081 HandToReset->ReleaseObject();
1082
1083 if(HandToReset->HandMesh->GetAnimInstance()->GetClass()->ImplementsInterface(UHandAnimationInterface::StaticClass()))
1084 IHandAnimationInterface::Execute_SetAnimationGripState(HandToReset->HandMesh->GetAnimInstance(),EPixoVRGripState::Open);
1085}
1086
1087void APixoVRCharacter::ShowTool(EControllerHand Hand, AActor* Tool)
1088{
1089 const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true);
1090
1091 switch(Hand)
1092 {
1093 case EControllerHand::Left:
1094 Tool->SetActorLocation(VRHandLeft->HandMesh->GetSocketLocation(ToolSocket));
1096 break;
1097 case EControllerHand::Right:
1098 Tool->SetActorLocation(VRHandRight->HandMesh->GetSocketLocation(ToolSocket));
1100 break;
1101 }
1102}
1103
1105{
1106 if (HintManager)
1107 {
1108 HintManager->HintActivated(false);
1109 }
1110 else
1111 UE_LOG(LogTemp, Error, TEXT("HintManager isn't initialized"));
1112}
1113
1115{
1116 if (HintManager)
1117 {
1119 }
1120 else
1121 UE_LOG(LogTemp, Error, TEXT("HintManager isn't initialized"));
1122}
1123
1125{
1127 {
1128 LaserControllerRight->Destroy();
1129 }
1130
1132 {
1133 LaserControllerLeft->Destroy();
1134 }
1135
1136 if (WristMenu)
1137 {
1138 WristMenu->Destroy();
1139 }
1140
1142 {
1144 }
1145
1147 {
1149 }
1150}
1151
1152void APixoVRCharacter::HandleTeleportRightRight_Implementation(float Value)
1153{
1155}
1156
1157bool APixoVRCharacter::HandleTeleportRightRight_Validate(float Value)
1158{
1159 return true;
1160}
1161
1162void APixoVRCharacter::HandleTeleportRightUp_Implementation(float Value)
1163{
1165}
1166
1167bool APixoVRCharacter::HandleTeleportRightUp_Validate(float Value)
1168{
1169 return true;
1170}
1171
1172void APixoVRCharacter::HandleTeleportLeftRight_Implementation(float Value)
1173{
1175}
1176
1177bool APixoVRCharacter::HandleTeleportLeftRight_Validate(float Value)
1178{
1179 return true;
1180}
1181
1182void APixoVRCharacter::HandleTeleportLeftUp_Implementation(float Value)
1183{
1185}
1186
1187bool APixoVRCharacter::HandleTeleportLeftUp_Validate(float Value)
1188{
1189 return true;
1190}
1191
1193{
1194 ActivateWristMenu(EControllerHand::Left);
1195}
1196
1198{
1199 ActivateWristMenu(EControllerHand::Right);
1200}
1201
1203{
1204 if (LastPressedKey == InputKey)
1205 {
1207 }
1208 else
1209 {
1210 LastPressedKey = InputKey;
1211 }
1212}
1213
1214void APixoVRCharacter::SpawnProgressBar_Implementation()
1215{
1216 const FAttachmentTransformRules ProgressBarAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true);
1217 FActorSpawnParameters ActorSpawnParameters = {};
1218
1219 ActorSpawnParameters.Owner = this;
1220 ActorSpawnParameters.Instigator = this;
1221
1222 if (ProgressBar)
1223 {
1224 ProgressBar = GetWorld()->SpawnActor<APixoVRCircleProgress>(ProgressBarClass, ActorSpawnParameters);
1225 ProgressBar->AttachToComponent(VRHandLeft->HandMesh, ProgressBarAttachmentTransformRules, WristMenuSocket);
1226 }
1227}
1228
1229bool APixoVRCharacter::SpawnProgressBar_Validate()
1230{
1231 return true;
1232}
1233
1234void APixoVRCharacter::SpawnWristMenu_Implementation()
1235{
1236 if(WristMenuClass)
1237 {
1238 const FAttachmentTransformRules WristMenuAttachmentTransformRules(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true);
1239
1240 FActorSpawnParameters ActorSpawnParameters = {};
1241 ActorSpawnParameters.Owner = this;
1242 ActorSpawnParameters.Instigator = this;
1243
1244 WristMenu = GetWorld()->SpawnActor<APixoVRWristMenu>(WristMenuClass, ActorSpawnParameters);
1245 WristMenu->AttachToComponent(VRHandLeft->HandMesh, WristMenuAttachmentTransformRules, WristMenuSocket);
1246 }
1247}
1248
1249bool APixoVRCharacter::SpawnWristMenu_Validate()
1250{
1251 return true;
1252}
1253
1254void APixoVRCharacter::ActivateProgressBar_Implementation(EControllerHand Hand, bool InActivate)
1255{
1256 const auto CurrentHand = Hand == EControllerHand::Left ? VRHandLeft->HandMesh : VRHandRight->HandMesh;
1257
1258 const FAttachmentTransformRules ProgressBarAttachment(EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, EAttachmentRule::KeepRelative, true);
1259
1260 if (ProgressBar)
1261 {
1262 ProgressBar->AttachToComponent(CurrentHand, ProgressBarAttachment, WristMenuSocket);
1263 ProgressBar->SetActorScale3D(Hand == EControllerHand::Left ? FVector(1) : MirroredWristMenuScale);
1265 }
1266}
1267
1268bool APixoVRCharacter::ActivateProgressBar_Validate(EControllerHand Hand, bool InActivate)
1269{
1270 return true;
1271}
1272
1273void APixoVRCharacter::ActivateWristMenu_Implementation(EControllerHand Hand)
1274{
1275 if (!WristMenu)
1276 {
1277 return;
1278 }
1279
1280 ActivateProgressBar(Hand, false);
1281 LastPressedKey = "None";
1282
1283 const auto CurrentHand = Hand == EControllerHand::Left ? VRHandLeft->HandMesh : VRHandRight->HandMesh;
1284
1285 const FAttachmentTransformRules WristMenuAttachmentTransformRules(EAttachmentRule::KeepRelative,
1286 EAttachmentRule::KeepRelative,
1287 EAttachmentRule::KeepRelative, true);
1288
1289 const auto PlatformName = UGameplayStatics::GetPlatformName();
1290
1291 if (PlatformName == "Windows" || PlatformName == "Mac" || PlatformName == "Linux")
1292 {
1293 WristMenu->AttachToComponent(WristMenuLoc, WristMenuAttachmentTransformRules);
1295 }
1296 else
1297 {
1298 WristMenu->AttachToComponent(CurrentHand, WristMenuAttachmentTransformRules, WristMenuSocket);
1299 }
1300
1301 // Mirror wrist if it is for right hand, as left hand was default before.
1302 if (Hand == EControllerHand::Left)
1303 {
1304 WristMenu->SetActorScale3D(FVector(1));
1305 }
1306 else
1307 {
1308 WristMenu->SetActorScale3D(MirroredWristMenuScale);
1309 }
1310
1311 if (WristMenu->IsActivated())
1312 {
1313 if (CurrentWristMenuHand == Hand)
1314 {
1316 }
1317 }
1318 else
1319 {
1321 }
1322
1323 CurrentWristMenuHand = Hand;
1324
1325 OnWristMenuActivated.Broadcast(Hand);
1326}
1327
1328bool APixoVRCharacter::ActivateWristMenu_Validate(EControllerHand Hand)
1329{
1330 return true;
1331}
1332
1334{
1335 ActivateWristMenu(EControllerHand::Left);
1336}
1337
1351
1352void APixoVRCharacter::SelectWristMenu(EControllerHand Hand)
1353{
1354 if(Hand == CurrentWristMenuHand)
1355 {
1357 }
1358}
1359
1361{
1362 if (EControllerHand::Left == CurrentWristMenuHand)
1363 {
1365 }
1366}
1367
1369{
1370 if (EControllerHand::Right == CurrentWristMenuHand)
1371 {
1373 }
1374}
1375
1380
1385
1390
1395
1400
1405
1410
EPixoVRGripState
Enumeration for different grip states for hand animation in PixoVR.
DEFINE_LOG_CATEGORY(LogPixoVRCharacter)
Pixo VR Character This class represents the main character in the Pixo VR game. It extends the AVRCha...
FName LeftTeleporterSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
APixoVRCircleProgress * ProgressBar
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR", meta = (AllowPrivateAccess = "true"))
bool bActivateRightLaser
UPROPERTY(BlueprintReadOnly, Replicated)
bool bIsOverWidgetUse
UPROPERTY(Replicated)
float DefaultPlayerHeight
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "PixoVR")
bool bActivateLeftLaser
UPROPERTY(BlueprintReadOnly, Replicated)
bool bLeftLaserBeamIsActiveOnStart
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "PixoVR")
void HandleLaserSelectEvent(EControllerHand Hand, bool Pressed)
UFUNCTION(Server, Reliable)
virtual void HandleWristMenuItem3Pressed()
virtual bool CanTeleport() const
EControllerHand CurrentWristMenuHand
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Replicated, Category= "PixoVR")
virtual void HandleWristMenuItem1Pressed()
void DeactivateHint()
UFUNCTION(BlueprintCallable, Category = "Hint")
void PlayerDestroyed(AActor *Act)
UFUNCTION()
void ActivateHint()
UFUNCTION(BlueprintCallable, Category = "Hint")
FVector2D LastTeleportLeftDirectionVector
void HandleSelectWristMenuItemPressed()
UFUNCTION(BlueprintCallable)
void ExecuteTeleportation(EControllerHand Hand)
UFUNCTION()
virtual void GrabLeftPressed()
UFUNCTION(BlueprintCallable, Category = "Hands")
TSubclassOf< APixoVRCircleProgress > ProgressBarClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
APixoVRLaser * LaserControllerRight
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR")
void HandleTeleportLeftRight(float Value)
UFUNCTION(Server, Unreliable, WithValidation)
void IsOverWidgetUse(EControllerHand Hand, bool InPressed)
UFUNCTION(Server, Reliable, WithValidation)
virtual void GrabRightPressed()
UFUNCTION(BlueprintCallable, Category = "Hands")
FName LeftLaserBeamSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
APixoVRHand * VRHandLeft
UPROPERTY(BlueprintReadOnly, Category = "Hands")
virtual void BeginPlay() override
void ActivateWristMenu(EControllerHand Hand)
Activate/Deactivate the Wrist Menu.
void HandleHandAnimationLaser(EControllerHand Hand)
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category ="PixoVR")
virtual void PossessedBy(AController *NewController) override
TSubclassOf< APixoVRWristMenu > WristMenuClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
TSubclassOf< APixoVRLaser > LaserControllerClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
UDataTable * InputsTable
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="PixoVR")
void SpawnLaserBeam(EControllerHand Hand, bool InActivate)
UFUNCTION()
APixoVRTeleporter * TeleportControllerLeft
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR")
void HandleTeleportRightReleased()
UFUNCTION(BlueprintCallable)
void PerformIsOverWidgetUse(EControllerHand Hand, bool InPressed)
UFUNCTION(Client, Reliable)
void ResetHand(bool RightHand)
Reset hand animation to Open state and drop any object holding.
virtual void HandleWristMenuItem8Pressed()
void TurnAtRate(float Rate)
FName RightLaserBeamSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
UHintManager * HintManager
UPROPERTY(BlueprintReadOnly)
FName RightTeleporterSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
bool bTeleporterEnabled
Allows for disabling of Teleporter via BP.
virtual void TurnVRRight()
void HandleTeleportLeftPressed()
UFUNCTION(BlueprintCallable)
FVector MirroredWristMenuScale
virtual void HandleSelectWristMenuItemPressedLeft()
void HandleLaserSelect(EControllerHand Hand, bool Pressed)
UFUNCTION()
void LookUpAtRate(float Rate)
UStaticMeshComponent * Body
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "PixoVR", meta = (AllowPrivateAccess = "tru...
TSubclassOf< APixoVRTeleporter > TeleportControllerClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
void ActivateTeleporter(EControllerHand Hand, bool InActivate)
Activate/Deactivate the Teleporter.
void HandleActivateWristMenuPressedRight()
UFUNCTION(BlueprintCallable)
virtual void HandleWristMenuDoubleTap(FKey InputKey)
bool bRightLaserBeamIsActiveOnStart
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "PixoVR")
void HandleTeleportLeftUp(float Value)
UFUNCTION(Server, Unreliable, WithValidation)
FVector2D LastTeleportRightDirectionVector
void MoveRight(float Value)
UPixoVRLongHoldComponent * LongHoldComponent
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "PixoVR", meta = (AllowPrivateAccess = "tru...
void IsLaserActivated(bool &IsActivated, EControllerHand &Hand)
UStaticMeshComponent * Head
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "PixoVR", meta = (AllowPrivateAccess = "tru...
void ActivateProgressBar(EControllerHand Hand, bool InActivate)
UFUNCTION(BlueprintCallable, Server, Reliable, WithValidation, Category = "PixoVR")
APixoVRHand * VRHandRight
UPROPERTY(BlueprintReadOnly, Category = "Hands")
void HandleActivateWristMenuPressedLeft()
UFUNCTION(BlueprintCallable)
APixoVRWristMenu * WristMenu
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR", meta = (AllowPrivateAccess = "true"))
void MultiHandleLaserSelectEvent(EControllerHand Hand, bool Pressed)
UFUNCTION(NetMulticast, Reliable)
APixoVRLaser * LaserControllerLeft
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR")
void SpawnTeleporter(EControllerHand Hand, bool InActivate)
UFUNCTION()
void MulticastActivateTeleporter(EControllerHand Hand, bool InActivate)
UFUNCTION(BlueprintCallable, NetMulticast, Reliable, Category = "PixoVR")
virtual void HandleWristMenuItem6Pressed()
virtual void SetupPlayerInputComponent(UInputComponent *PlayerInputComponent) override
void ActivateLaserBeam(EControllerHand Hand, bool InActivate)
Activate/Deactivate the Laser-beam.
FOnTeleportationActivated & OnTeleportationActivated()
USceneComponent * WristMenuLoc
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "PixoVR")
void HandleLaserBeamLeftPressed()
UFUNCTION(BlueprintCallable)
bool bLaserBeamActive
UPROPERTY(BlueprintReadWrite, Category = "PixoVR")
float DeflectionAngle
The angle by which we rotate the player.
UStaticMeshComponent * FadeSphere
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fade")
virtual void HandleWristMenuItem5Pressed()
void HandleTeleportRightRight(float Value)
UFUNCTION(Server, Unreliable, WithValidation)
void HandleActivateWristMenuPressed()
UFUNCTION(BlueprintCallable)
virtual void HandleSelectWristMenuItemPressedRight()
void MoveForward(float Value)
UPixoVRInputAdapter * InputAdapter
UPROPERTY()
AActor * SpawnActorInHand(TSubclassOf< AActor > ActorClass, bool RightHand)
UFUNCTION(BlueprintCallable, Category = "Hands")
void ActivateFPSMode(bool Enable)
For Windows.
virtual void Tick(float DeltaTime) override
TSubclassOf< APixoVRHand > VRHandClass
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hands")
void SelectWristMenu(EControllerHand Hand)
UFUNCTION(BlueprintCallable)
void ShowTool(EControllerHand Hand, AActor *Tool)
UFUNCTION(BlueprintCallable)
void HandleTeleportLeftReleased()
UFUNCTION(BlueprintCallable)
void HandleTeleportRightUp(float Value)
UFUNCTION(Server, Unreliable, WithValidation)
FName ToolSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
FName WristMenuSocket
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR")
FOnHandGrabAction OnHandGrabAction
UPROPERTY(BlueprintAssignable, Category = "Hands")
virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty > &OutLifetimeProps) const override
void HandleTeleportRightPressed()
UFUNCTION(BlueprintCallable)
virtual void GrabLeftReleased()
UFUNCTION(BlueprintCallable, Category = "Hands")
virtual void TurnVRLeft()
FOnWristMenuActivated OnWristMenuActivated
UPROPERTY(BlueprintAssignable)
void NotifyActivateTeleporter(EControllerHand Hand, bool InActivate)
UFUNCTION(BlueprintCallable, Server, Reliable, WithValidation, Category = "PixoVR")
void ResetHandHoldingObject()
UFUNCTION(BlueprintCallable, Category = "Hands")
virtual void GrabRightReleased()
UFUNCTION(BlueprintCallable, Category = "Hands")
void HandleLaserBeamRightPressed()
UFUNCTION(BlueprintCallable)
virtual void HandleWristMenuItem2Pressed()
APixoVRTeleporter * TeleportControllerRight
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR")
void SpawnWristMenu()
UFUNCTION(Server, Reliable, WithValidation)
virtual void HandleWristMenuItem7Pressed()
void SpawnProgressBar()
UFUNCTION(Server, Reliable, WithValidation)
virtual void HandleWristMenuItem4Pressed()
Class representing a circular progress indicator in PixoVR. The circle progress can be updated to dis...
void SetCircleProgressEnabled(bool bIsEnabled)
Sets the enabled state of the circle progress.
APixoVRHand is an actor class that represents a hand in the VR environment.
Definition PixoVRHand.h:99
void ManuallyPutActorToHand(AActor *ActorRef)
Manually puts an actor into the hand. Hand will try to grab this actor.
USkeletalMeshComponent * HandMesh
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components")
Definition PixoVRHand.h:130
void GrabObject()
Grabs the object currently overlapped by grab sphere.
void InitPixoVRHands(EControllerHand MotionSource, APixoVRCharacter *Character)
UGripMotionControllerComponent * MotionController
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components")
Definition PixoVRHand.h:118
void ReleaseObject()
Releases the currently held object.
UObject * HandHoldingObject
UPROPERTY(BlueprintReadOnly, Replicated, Category = "PixoVR")
Definition PixoVRHand.h:228
void ToggleLaser(bool Visible)
Toggles the visibility of the laser.
Class for VR laser interaction. It can interact with widget buttons or actors derived from IPixoVRInt...
Definition PixoVRLaser.h:23
bool IsOverWidgetUse(bool InPressed)
Check if the laser is over a widget and simulate button press.
void TriggerSelect(bool State)
Call this method when the user wants to select the hovered object.
void SetHandType(EControllerHand HandType, bool InIsLocal)
Set the hand type describing which hand is holding it.
UWidgetInteractionComponent * WidgetInteraction
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)
void ActivateLaserBeam(bool InActivate)
Activate or deactivate the laser beam.
bool bIsLaserBeamActive
UPROPERTY(BlueprintReadOnly, Transient, ReplicatedUsing=OnRep_LaserBeamActive, Category = "PixoVR | L...
Class for VR teleporter functionality. It allows teleportation using visual indicators.
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 ActivateTeleporter(bool InActivate)
Activate or deactivate the Teleporter.
bool IsActivated()
Check if the teleporter is activated.
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.
A actor class representing the PixoVR wrist menu. The wrist menu allows users to interact with menu i...
bool bAlignToPlayerHead
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PixoVR | Wrist Menu")
EWristMenuItemCategory SelectMenuItem()
Signal that the user has performed a select action on the wrist menu.
bool IsActivated()
Check if the wrist menu is activated.
void ActivateWristMenu(bool InActivate)
Activate or deactivate the wrist menu.
void CalculateRotationByItemIndex(const int32 WristMenuItemIndex)
Calculate the rotation of the pointer arrow based on the item index.
void UpdateTrackpadPosition(const FVector2D &position)
Update the position of the trackpad. You need to call this method when the user moves his fingers (th...
USceneComponent * VRProxyComponent
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UGripMotionControllerComponent * RightMotionController
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
FVector GetVRForwardVector() const
UFUNCTION(BlueprintPure, Category = "BaseVRCharacter|VRLocations")
void Server_SendTransformRightController(FBPVRComponentPosRep NewTransform)
UFUNCTION(Unreliable, Server, WithValidation)
FVector GetVRLocation() const
UFUNCTION(BlueprintPure, Category = "BaseVRCharacter|VRLocations")
FVector AddActorWorldRotationVR(FRotator DeltaRot, bool bUseYawOnly=true)
UFUNCTION(BlueprintCallable, Category = "BaseVRCharacter|VRLocations")
FVector GetVRRightVector() const
UFUNCTION(BlueprintPure, Category = "BaseVRCharacter|VRLocations")
UVRBaseCharacterMovementComponent * VRMovementReference
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, Transient, BlueprintReadOnly,...
UReplicatedVRCameraComponent * VRReplicatedCamera
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UGripMotionControllerComponent * LeftMotionController
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UParentRelativeAttachmentComponent * ParentRelativeAttachment
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
void Server_SendTransformLeftController(FBPVRComponentPosRep NewTransform)
UFUNCTION(Unreliable, Server, WithValidation)
VRBaseCharTransformRPC_Pointer OverrideSendTransform
void HintActivated(bool Activate)
This function is called when a hint is activated or deactivated. Broadcasts UHintActivatedEvent and O...
void ResolveMappings(const UDataTable *MappingsTable)
UINTERFACE(MinimalAPI)
uint32 bAutoSetLockToHmd
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ReplicatedCamera|Advanced|Tracking")