A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
PixoVRPlayerController.cpp
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
4#include "PixoVRCharacter.h"
5#include "Math/NumericLimits.h"
6
8{
9 static ConstructorHelpers::FObjectFinder<UCurveFloat> FadeOpacityCurveAsset(TEXT("CurveFloat'/PixoCore/Blueprints/FadeOpacityCurve.FadeOpacityCurve'"));
10 ChangingFadeOpacityCurve = FadeOpacityCurveAsset.Object;
11}
12
14{
15 Super::BeginPlay();
16
17 if (ChangingFadeOpacityCurve != nullptr)
18 {
19 FOnTimelineFloat TimelineProgress;
20 TimelineProgress.BindUFunction(this, FName("FadeOpacityTimelineProgress"));
21 FadeTimeline.AddInterpFloat(ChangingFadeOpacityCurve, TimelineProgress);
22
23 FadeTimeline.SetLooping(false);
24 }
25 else
26 {
27 GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "APixoVRPlayerController::BeginPlay Setup ChangingFadeOpacityCurve");
28 }
29}
30
31void APixoVRPlayerController::Tick(float DeltaTime)
32{
33 Super::Tick(DeltaTime);
34
35 FadeTimeline.TickTimeline(DeltaTime);
36}
37
38void APixoVRPlayerController::ClientFadeIn_Implementation(float FadeDuration)
39{
40 FadeIn(FadeDuration);
41}
42
43void APixoVRPlayerController::FadeIn(float FadeDuration)
44{
45 if (FadeDuration > MIN_flt)
46 {
47 FadeTimeline.SetPlayRate(1.0f / FadeDuration);
48 FadeTimeline.PlayFromStart();
49 }
50 else
51 {
53 }
54}
55
56void APixoVRPlayerController::ClientFadeOut_Implementation(float FadeDuration)
57{
58 FadeOut(FadeDuration);
59}
60
61void APixoVRPlayerController::FadeOut(float FadeDuration)
62{
63 if (FadeDuration > MIN_flt)
64 {
65 FadeTimeline.SetPlayRate(1.0f / FadeDuration);
66 FadeTimeline.ReverseFromEnd();
67 }
68 else
69 {
71 }
72}
73
74void APixoVRPlayerController::PlayHapticFeedback(bool RightHand, float Duration, float Strength)
75{
76 EControllerHand Hand = EControllerHand::Left;
77 if (RightHand)
78 Hand = EControllerHand::Right;
79
80 SetHapticsByValue(1.0, Strength, Hand);
81
82 if (Duration > 0)
83 {
84 auto DisableHaptic = [this, Hand](){ SetHapticsByValue(0,0,Hand);};
85 FTimerHandle TimerHandle;
86 FTimerDelegate TimerDelegate;
87 TimerDelegate.BindLambda(DisableHaptic);
88 GetWorldTimerManager().SetTimer(TimerHandle, TimerDelegate, Duration, false);
89 }
90}
91
93{
94 APixoVRCharacter* PixoCharacter = Cast<APixoVRCharacter>(GetCharacter());
95
96 PixoCharacter->FadeSphere->SetScalarParameterValueOnMaterials("FadeOpacity", Value);
97}
98
100{
101 APixoVRCharacter* PixoCharacter = Cast<APixoVRCharacter>(GetCharacter());
102
103 PixoCharacter->FadeSphere->SetScalarParameterValueOnMaterials("FadeOpacity", 1.0f);
104}
105
107{
108 APixoVRCharacter* PixoCharacter = Cast<APixoVRCharacter>(GetCharacter());
109
110 PixoCharacter->FadeSphere->SetScalarParameterValueOnMaterials("FadeOpacity", 0.0f);
111}
@ FadeIn
@ FadeOut
Pixo VR Character This class represents the main character in the Pixo VR game. It extends the AVRCha...
UStaticMeshComponent * FadeSphere
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Fade")
virtual void Tick(float DeltaTime) override
void FadeOut(float FadeDuration=1.0f)
UFUNCTION(BlueprintCallable, Category = "Fade")
void FadeOpacityTimelineProgress(float Value)
UFUNCTION()
void FadeIn(float FadeDuration=1.0f)
UFUNCTION(BlueprintCallable, Category = "Fade")
UCurveFloat * ChangingFadeOpacityCurve
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Fade")
virtual void BeginPlay() override
void PlayHapticFeedback(bool RightHand, float Duration, float Strength)
UFUNCTION(BlueprintCallable, Category = "Haptic")