A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
VRSimpleCharacter.cpp
Go to the documentation of this file.
1// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
2
4//#include "Runtime/Engine/Private/EnginePrivate.h"
5
6AVRSimpleCharacter::AVRSimpleCharacter(const FObjectInitializer& ObjectInitializer)
7 : Super(ObjectInitializer.SetDefaultSubobjectClass<UVRSimpleCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
8
9{
10
11 // Remove the movement jitter with slow speeds
12 FRepMovement& MovementRep = GetReplicatedMovement_Mutable();
13 MovementRep.LocationQuantizationLevel = EVectorQuantization::RoundTwoDecimals;
14
15 VRMovementReference = Cast<UVRBaseCharacterMovementComponent>(GetMovementComponent());
18
19 VRSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("VR Scene Component"));
20
22 {
23 VRSceneComponent->SetupAttachment(NetSmoother);
24 VRSceneComponent->SetRelativeLocation(FVector(0, 0, -96));
25 }
26
27 //VRReplicatedCamera = CreateDefaultSubobject<UReplicatedVRCameraComponent>(TEXT("VR Replicated Camera"));
29 {
31 VRReplicatedCamera->SetupAttachment(VRSceneComponent);
32 }
33
34 /*VRHeadCollider = CreateDefaultSubobject<UCapsuleComponent>(TEXT("VR Head Collider"));
35 if (VRHeadCollider && VRReplicatedCamera)
36 {
37 VRHeadCollider->SetCapsuleSize(20.0f, 25.0f);
38 VRHeadCollider->SetupAttachment(VRReplicatedCamera);
39 }*/
40
41// ParentRelativeAttachment = CreateDefaultSubobject<UParentRelativeAttachmentComponent>(TEXT("Parent Relative Attachment"));
43 {
46 }
47
49 {
51
53 {
54 LeftMotionController->SetupAttachment(VRSceneComponent);
55 }
56 }
57
58 //RightMotionController = CreateDefaultSubobject<UGripMotionControllerComponent>(TEXT("Right Grip Motion Controller"));
60 {
62
64 {
66 }
67 }
68}
69
71{
72 Super::BeginPlay();
73
74 // I am re-forcing these to true here
75 // The editor loses these values sometimes when copying over from the std character
76 // And I like copying since it saves me hours of work.
77
80
83
86
89
90}
91
92FVector AVRSimpleCharacter::GetTeleportLocation(FVector OriginalLocation)
93{
94 //FVector modifier = VRRootReference->GetVRLocation_Inline() - this->GetActorLocation();
95 //modifier.Z = 0.0f; // Null out Z
96 //return OriginalLocation - modifier;
97
98 return OriginalLocation;
99}
100
101bool AVRSimpleCharacter::TeleportTo(const FVector& DestLocation, const FRotator& DestRotation, bool bIsATest, bool bNoCheck)
102{
103 bool bTeleportSucceeded = Super::TeleportTo(DestLocation + FVector(0,0,GetCapsuleComponent()->GetScaledCapsuleHalfHeight()), DestRotation, bIsATest, bNoCheck);
104
105 if (bTeleportSucceeded)
106 {
108 }
109
110 return bTeleportSucceeded;
111}
USceneComponent * NetSmoother
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UGripMotionControllerComponent * RightMotionController
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UVRBaseCharacterMovementComponent * VRMovementReference
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, Transient, BlueprintReadOnly,...
UReplicatedVRCameraComponent * VRReplicatedCamera
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
virtual void NotifyOfTeleport(bool bRegisterAsTeleport=true)
UFUNCTION(BlueprintCallable, Category = "VRGrip")
UGripMotionControllerComponent * LeftMotionController
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
UParentRelativeAttachmentComponent * ParentRelativeAttachment
UPROPERTY(Category = VRBaseCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess ...
USceneComponent * VRSceneComponent
UPROPERTY(Category = VRSimpleCharacter, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAcces...
AVRSimpleCharacter(const FObjectInitializer &ObjectInitializer=FObjectInitializer::Get())
virtual FVector GetTeleportLocation(FVector OriginalLocation) override
UFUNCTION(BlueprintPure, Category = "VRGrip")
virtual void BeginPlay() override
virtual bool TeleportTo(const FVector &DestLocation, const FRotator &DestRotation, bool bIsATest=false, bool bNoCheck=false) override
bool bOffsetByHMD
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GripMotionController|Advanced|Tracking")
bool bOffsetByHMD
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRExpansionLibrary")
bool bOffsetByHMD
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ReplicatedCamera")