From 349f3928d60109669178af84adf1102edff28377 Mon Sep 17 00:00:00 2001 From: Ehret <jw210150@WIN.RZ.RWTH-AACHEN.DE> Date: Wed, 21 Apr 2021 23:26:52 +0200 Subject: [PATCH] make pawn render nicely in editor (camera at eye level capsule on top of floor --- .../Private/Pawn/VRPawnMovement.cpp | 10 ++++++---- .../Private/Pawn/VirtualRealityPawn.cpp | 1 + .../Public/Pawn/VRPawnMovement.h | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/DisplayClusterExtensions/Private/Pawn/VRPawnMovement.cpp b/Source/DisplayClusterExtensions/Private/Pawn/VRPawnMovement.cpp index 182c2b5e..b11f6bd8 100644 --- a/Source/DisplayClusterExtensions/Private/Pawn/VRPawnMovement.cpp +++ b/Source/DisplayClusterExtensions/Private/Pawn/VRPawnMovement.cpp @@ -8,7 +8,7 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) : CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block); - CapsuleColliderComponent->SetCapsuleSize(40.0f, 96.0f); + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, 80.0f); } void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){ @@ -61,6 +61,9 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent) { HeadComponent = NewHeadComponent; CapsuleColliderComponent->SetupAttachment(HeadComponent); + const float HalfHeight = 80.0f; //this is just an initial value to look good in editor + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, HalfHeight); + CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f,HalfHeight)); } void UVRPawnMovement::SetCapsuleColliderToUserSize() @@ -71,14 +74,13 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize() { float ColliderHeight = CharachterSize - MaxStepHeight; float ColliderHalfHeight = ColliderHeight / 2.0f; - float ColliderRadius = 40.0f; - if (ColliderHalfHeight <= ColliderRadius) + if (ColliderHalfHeight <= CapsuleRadius) {//Make the collider to a Sphere CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight); } else {//Make the collider to a Capsule - CapsuleColliderComponent->SetCapsuleSize(ColliderRadius, ColliderHalfHeight); + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight); } CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); diff --git a/Source/DisplayClusterExtensions/Private/Pawn/VirtualRealityPawn.cpp b/Source/DisplayClusterExtensions/Private/Pawn/VirtualRealityPawn.cpp index 86d98492..49b74b7e 100644 --- a/Source/DisplayClusterExtensions/Private/Pawn/VirtualRealityPawn.cpp +++ b/Source/DisplayClusterExtensions/Private/Pawn/VirtualRealityPawn.cpp @@ -25,6 +25,7 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera")); CameraComponent->SetupAttachment(RootComponent); + CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, BaseEyeHeight)); //so it is rendered correctly in editor Head = CreateDefaultSubobject<UUniversalTrackedComponent>(TEXT("Head")); Head->ProxyType = ETrackedComponentType::TCT_HEAD; diff --git a/Source/DisplayClusterExtensions/Public/Pawn/VRPawnMovement.h b/Source/DisplayClusterExtensions/Public/Pawn/VRPawnMovement.h index 31bb8611..d90c30c7 100644 --- a/Source/DisplayClusterExtensions/Public/Pawn/VRPawnMovement.h +++ b/Source/DisplayClusterExtensions/Public/Pawn/VRPawnMovement.h @@ -52,6 +52,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") float UpSteppingAcceleration = 500.0f; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + float CapsuleRadius = 40.0f; + private: FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility); FHitResult CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility); -- GitLab