Skip to content
Snippets Groups Projects
Select Git revision
  • 3b500ecd9b38734e030b52b1a49b5f6aabc5bdf4
  • 5.4 default protected
  • 5.5
  • dev/5.5
  • dev/5.4
  • dev/5.3_downgrade
  • feature/experimenttime_hack
  • 5.3 protected
  • _IntenSelect5.3
  • IntenSelect5.3
  • 4.27 protected
  • 4.26 protected
  • 5.0 protected
  • 4.22 protected
  • 4.21 protected
  • UE5.4-2024.1
  • UE5.4-2024.1-rc1
  • UE5.3-2023.1-rc3
  • UE5.3-2023.1-rc2
  • UE5.3-2023.1-rc
20 results

CollisionHandlingMovement.h

Blame
  • CollisionHandlingMovement.h 3.93 KiB
    #pragma once
    
    #include "CoreMinimal.h"
    #include "GameFramework/FloatingPawnMovement.h"
    #include "Components/CapsuleComponent.h"
    
    #include "CollisionHandlingMovement.generated.h"
    
    /*
     * This Movement component is needed since in VR not only the pawn itself (UpdatedComponent) is moved but also the
     * user herself can walk and thereby move the CameraComponent, which can also lead to collisions or e.g. going up steps
     *
     * The four modes are:
     * - None: No controller movement is applied and no corrections regarding steps or collisions with walls are done
     * - Ghost: The same as above but now the Inputs can be used for unconstrained flying (also through objects)
     * - Fly: The user can fly but not through walls etc. When the user walks against a wall the scene is moved with her to
     *     avoid walking through The user can also walk up stairs with a maximum step height of MaxStepHeight
     * - Walk: Additionally to Fly, now gravity keeps the user on the floor
     */
    
    UENUM(BlueprintType)
    enum class EVRNavigationModes : uint8
    {
    	NAV_NONE UMETA(DisplayName = "None (no controller movement)"),
    	NAV_GHOST UMETA(DisplayName = "Ghost (flying, also through walls)"),
    	NAV_FLY UMETA(DisplayName = "Fly (prohibiting collisions)"),
    	NAV_WALK UMETA(DisplayName = "Walk (gravity and prohibiting collisions)")
    };
    
    UCLASS()
    class RWTHVRTOOLKIT_API UCollisionHandlingMovement : public UFloatingPawnMovement
    {
    	GENERATED_UCLASS_BODY()
    
    public:
    	virtual void BeginPlay() override;
    	void CheckAndRevertCollisionSinceLastTick();
    
    	void MoveOutOfNewDynamicCollisions();
    	virtual void TickComponent(float DeltaTime, enum ELevelTick TickType,
    							   FActorComponentTickFunction* ThisTickFunction) override;
    
    	void SetHeadComponent(USceneComponent* NewHeadComponent);
    
    	UFUNCTION(BlueprintCallable)
    	bool AddActorToIgnore(AActor* ActorToIgnore);
    
    	UFUNCTION(BlueprintCallable)
    	bool RemoveActorFromIgnore(AActor* ActorToIgnore);
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
    	EVRNavigationModes NavigationMode = EVRNavigationModes::NAV_WALK;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin = "0.0"))
    	float MaxStepHeight = 40.0f;
    
    	// if the height that the pawn would fall (in walking mode) is higher
    	// it is not falling, set to <0.0f if you want to fall infinitely
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
    	float MaxFallingDepth = 1000.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMax = "0.0"))
    	float GravityAcceleration = -981.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin = "0.0"))
    	float UpSteppingAcceleration = 981.0f;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta = (ClampMin = "0.0"))
    	float CapsuleRadius = 40.0f;