Skip to content
Snippets Groups Projects
Commit 6028d654 authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

Improve VRPawnMovement to reduce the interface

Add method in pawn to make AddMovementInput work
parent 7638c93f
No related branches found
No related tags found
No related merge requests found

#include "VRPawnMovement.h"
#include "DrawDebugHelpers.h"
......@@ -9,6 +9,9 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) :
CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block);
CapsuleColliderComponent->SetCapsuleSize(40.0f, 96.0f);
CameraComponent = GetOwner()->FindComponentByClass<UCameraComponent>();
CapsuleColliderComponent->SetupAttachment(CameraComponent);
}
void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){
......@@ -57,13 +60,6 @@ bool UVRPawnMovement::CheckForVirtualMovCollision(FVector PositionChange, float
return false;
}
void UVRPawnMovement::SetCameraComponent(UCameraComponent* NewCameraComponent)
{
CameraComponent = NewCameraComponent;
CapsuleColliderComponent->SetupAttachment(CameraComponent);
}
void UVRPawnMovement::SetCapsuleColliderToUserSize()
{
float CharachterSize = abs(UpdatedComponent->GetComponentLocation().Z - CameraComponent->GetComponentLocation().Z);
......
......@@ -22,7 +22,7 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial
AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events.
PawnMovement = CreateDefaultSubobject<UVRPawnMovement>(TEXT("Pawn Movement"));
PawnMovement->UpdatedComponent = RootComponent;
PawnMovement->SetUpdatedComponent(RootComponent);
Head = CreateDefaultSubobject<UUniversalTrackedComponent>(TEXT("Head"));
Head->ProxyType = ETrackedComponentType::TCT_HEAD;
......@@ -114,3 +114,8 @@ void AVirtualRealityPawn::OnEndFire_Implementation()
{
BasicVRInteraction->EndInteraction();
}
UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent() const
{
return PawnMovement;
}
......@@ -38,8 +38,6 @@ public:
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
void SetCameraComponent(UCameraComponent* NewCameraComponent);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
EVRNavigationModes NavigationMode = EVRNavigationModes::Walk;
......
......@@ -45,4 +45,7 @@ protected:
/* Interaction */
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Interaction") void OnBeginFire();
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Interaction") void OnEndFire();
/* APawn Interface to be able to use AddMovementInput() */
virtual UPawnMovementComponent* GetMovementComponent() const override;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment