Skip to content
Snippets Groups Projects
Commit 349f3928 authored by Ehret's avatar Ehret
Browse files

make pawn render nicely in editor (camera at eye level capsule on top of floor

parent 593baa34
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) : ...@@ -8,7 +8,7 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) :
CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block); 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){ void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){
...@@ -61,6 +61,9 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent) ...@@ -61,6 +61,9 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent)
{ {
HeadComponent = NewHeadComponent; HeadComponent = NewHeadComponent;
CapsuleColliderComponent->SetupAttachment(HeadComponent); 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() void UVRPawnMovement::SetCapsuleColliderToUserSize()
...@@ -71,14 +74,13 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize() ...@@ -71,14 +74,13 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize()
{ {
float ColliderHeight = CharachterSize - MaxStepHeight; float ColliderHeight = CharachterSize - MaxStepHeight;
float ColliderHalfHeight = ColliderHeight / 2.0f; float ColliderHalfHeight = ColliderHeight / 2.0f;
float ColliderRadius = 40.0f; if (ColliderHalfHeight <= CapsuleRadius)
if (ColliderHalfHeight <= ColliderRadius)
{//Make the collider to a Sphere {//Make the collider to a Sphere
CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight); CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight);
} }
else else
{//Make the collider to a Capsule {//Make the collider to a Capsule
CapsuleColliderComponent->SetCapsuleSize(ColliderRadius, ColliderHalfHeight); CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight);
} }
CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation());
......
...@@ -25,6 +25,7 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial ...@@ -25,6 +25,7 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera")); CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
CameraComponent->SetupAttachment(RootComponent); CameraComponent->SetupAttachment(RootComponent);
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, BaseEyeHeight)); //so it is rendered correctly in editor
Head = CreateDefaultSubobject<UUniversalTrackedComponent>(TEXT("Head")); Head = CreateDefaultSubobject<UUniversalTrackedComponent>(TEXT("Head"));
Head->ProxyType = ETrackedComponentType::TCT_HEAD; Head->ProxyType = ETrackedComponentType::TCT_HEAD;
......
...@@ -52,6 +52,9 @@ public: ...@@ -52,6 +52,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
float UpSteppingAcceleration = 500.0f; float UpSteppingAcceleration = 500.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
float CapsuleRadius = 40.0f;
private: private:
FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility); FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility);
FHitResult CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility); FHitResult CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment