### Full Interaction UI Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Demonstrates the setup and event binding for various VR interactible UI components within an Actor. Ensure components are properly assigned in the editor or BeginPlay. ```cpp // Header UCLASS() class MYPROJECT_API AInteractionPanel : public AActor { GENERATED_BODY() public: AInteractionPanel(); virtual void BeginPlay() override; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI") class UVRButtonComponent* ConfirmButton; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI") class UVRSliderComponent* VolumeSlider; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI") class UVRDialComponent* BrightnessKnob; UFUNCTION() void OnButtonPressed(bool bState, AActor* InteractingActor, UPrimitiveComponent* InteractingComponent); UFUNCTION() void OnVolumeChanged(float NewValue); UFUNCTION() void OnBrightnessChanged(float NewValue); }; // Implementation AInteractionPanel::AInteractionPanel() { PrimaryActorTick.bCanEverTick = false; } void AInteractionPanel::BeginPlay() { Super::BeginPlay(); if (ConfirmButton) { ConfirmButton->ButtonType = EVRButtonType::Btn_Press; ConfirmButton->OnButtonStateChanged.AddDynamic(this, &AInteractionPanel::OnButtonPressed); } if (VolumeSlider) { VolumeSlider->SliderAxis = EVRInteractibleAxis::Axis_X; VolumeSlider->OnSliderValueChanged.AddDynamic(this, &AInteractionPanel::OnVolumeChanged); } if (BrightnessKnob) { BrightnessKnob->bUseSnapPoints = true; BrightnessKnob->SnapAngleIncrement = 30.0f; BrightnessKnob->OnDialValueChanged.AddDynamic(this, &AInteractionPanel::OnBrightnessChanged); } } void AInteractionPanel::OnButtonPressed(bool bState, AActor* InteractingActor, UPrimitiveComponent* InteractingComponent) { if (bState) { UE_LOG(LogTemp, Warning, TEXT("Confirmed!")); } } void AInteractionPanel::OnVolumeChanged(float NewValue) { float VolumeLevel = NewValue * 100.0f; UE_LOG(LogTemp, Warning, TEXT("Volume: %f%%"), VolumeLevel); } void AInteractionPanel::OnBrightnessChanged(float NewValue) { float BrightnessLevel = NewValue * 100.0f; UE_LOG(LogTemp, Warning, TEXT("Brightness: %f%%"), BrightnessLevel); } ``` -------------------------------- ### AGrippableStaticMeshActor Example Setup Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Example setup for an actor with a static mesh root that can be gripped. ```APIDOC ## Component: AGrippableStaticMeshActor Source: `VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/GrippableStaticMeshActor.h` Base: `AActor` + Static mesh root + `IVRGripInterface` ### Overview Complete actor with a static mesh root that can be gripped. Use this for simple prop-like objects. ### Example Setup ```cpp UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VRGrip") class UGrippableStaticMeshComponent* MeshComponent; void AGrippableStaticMeshActor::BeginPlay() { Super::BeginPlay(); // Configure grip behavior MeshComponent->GripCollisionType = EGripCollisionType::PhysicsOnly; MeshComponent->bAllowMultipleGrips = true; MeshComponent->GripStiffness = 2000.0f; } ``` ``` -------------------------------- ### Setup Smoothing Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Enables and configures hand tracking smoothing using Euro low-pass filter parameters. Ensure GripController is valid. ```cpp void AMyVRCharacter::SetupSmoothing() { if (!GripController) return; GripController->bSmoothHandTracking = true; GripController->bSmoothWithEuroLowPassFunction = true; GripController->EuroSmoothingParams.MinCutoff = 0.9; GripController->EuroSmoothingParams.DeltaCutoff = 1.0; GripController->EuroSmoothingParams.CutoffSlope = 0.007; } ``` -------------------------------- ### Setup Default Grip Script Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Example of how to set the default grip script class for a motion controller in C++. ```cpp void AMyCharacter::SetupDefaultGrip() { MotionController->DefaultGripScriptClass = UGS_Default::StaticClass(); } ``` -------------------------------- ### Get Gripped Info Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Logs the names of all currently gripped objects. Ensure GripController is valid. ```cpp void AMyVRCharacter::GetGrippedInfo() { TArray Grips; GripController->GetGrippedObjectsInfo(Grips); for (const FBPActorGripInformation& Grip : Grips) { UE_LOG(LogTemp, Warning, TEXT("Gripped: %s"), *Grip.GrippedObject->GetName()); } } ``` -------------------------------- ### Initialize and Configure GS_LerpToHand Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Example of creating and setting properties for the GS_LerpToHand grip script. ```cpp UGS_LerpToHand* LerpScript = NewObject(); LerpScript->LerpDuration = 0.5f; LerpScript->bLerpTransitionRotation = true; ``` -------------------------------- ### VRButtonComponent Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Demonstrates how to configure a VRButtonComponent and handle its state changes in a BlueprintCallable class. ```cpp UPROPERTY(EditAnywhere, BlueprintReadWrite) class UVRButtonComponent* InteractButton; void AMyUI::BeginPlay() { Super::BeginPlay(); if (InteractButton) { InteractButton->ButtonType = EVRButtonType::Btn_Press; InteractButton->DepressDistance = 10.0f; InteractButton->ButtonEngageDepth = 5.0f; InteractButton->OnButtonStateChanged.AddDynamic(this, &AMyUI::OnButtonPressed); } } void AMyUI::OnButtonPressed(bool bState, AActor* InteractingActor, UPrimitiveComponent* InteractingComponent) { if (bState) { UE_LOG(LogTemp, Warning, TEXT("Button pressed!")); } } ``` -------------------------------- ### Grip Object Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Example of gripping an actor to the controller without an offset. Ensure GripController is valid before calling. ```cpp // In a character or pawn class void AMyVRCharacter::GripObject() { if (!GripController) return; // Simple grip without offset GripController->GripObject( MyActorToGrip, FTransform::Identity, false, // world offset is absolute NAME_None, // no socket NAME_None, // no bone EGripCollisionType::ManipulationGrip ); } ``` -------------------------------- ### Seated Vehicle Cockpit Setup Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Example of setting up a cockpit actor that allows a VR character to enter a seated mode. This includes defining a seat location and handling player entry to adjust the character's seated state. ```cpp UCLASS() class MYPROJECT_API AVRCockpit : public AActor { GENERATED_BODY() public: AVRCockpit(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cockpit") class USceneComponent* SeatLocation; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cockpit") class UVRButtonComponent* StartButton; UFUNCTION() void OnPlayerEntered(AActor* Player); UFUNCTION() void OnPlayerExited(AActor* Player); }; void AVRCockpit::BeginPlay() { Super::BeginPlay(); if (StartButton) { StartButton->OnButtonStateChanged.AddDynamic(this, &AVRCockpit::OnEngineStart); } } void AVRCockpit::OnPlayerEntered(AActor* Player) { if (AVRBaseCharacter* VRChar = Cast(Player)) { VRChar->SetSeatedMode( SeatLocation, true, true, 80.0f, // Large radius for arm movements 40.0f ); } } ``` -------------------------------- ### Railcar Path Following Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-movement-locomotion.md Example demonstrating how to use UVRPathFollowingComponent to make a pawn follow a spline path, simulating a railcar ride. It sets up the spline, speed, and enables automatic progress. ```cpp UCLASS() class MYPROJECT_API ARailcar : public APawn { GENERATED_BODY() public: ARailcar(); virtual void BeginPlay() override; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Railcar") class USplineComponent* TrackSpline; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Railcar") float RideSpeed = 300.0f; UFUNCTION(BlueprintCallable, Category = "Railcar") void StartRide(); UFUNCTION(BlueprintCallable, Category = "Railcar") void StopRide(); }; void ARailcar::BeginPlay() { Super::BeginPlay(); if (UVRPathFollowingComponent* PathComp = FindComponentByClass()) { PathComp->SetSplinePath(TrackSpline); PathComp->SetFollowSpeed(RideSpeed); } } void ARailcar::StartRide() { if (UVRPathFollowingComponent* PathComp = FindComponentByClass()) { PathComp->SetPathProgress(0.0f); PathComp->bAutomaticProgress = true; } } ``` -------------------------------- ### Drop Object Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Example of dropping the first gripped object. Retrieves gripped objects information and then drops the first one found. Ensure GripController is valid. ```cpp void AMyVRCharacter::DropObject() { if (!GripController) return; TArray Grips; GripController->GetGrippedObjectsInfo(Grips); if (Grips.Num() > 0) { // Drop first grip GripController->DropGrip( Grips[0].GripID, FVector::ZeroVector, FVector::ZeroVector ); } } ``` -------------------------------- ### Enable Tracking Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Enables scaling of tracking and sets a minimum height limit. Ensure GripController is valid. ```cpp void AMyVRCharacter::EnableTracking() { if (!GripController) return; GripController->bScaleTracking = true; GripController->TrackingScaler = FVector(0.5f, 0.5f, 0.5f); GripController->bLimitMinHeight = true; GripController->MinimumHeight = 50.0f; } ``` -------------------------------- ### Configure and Use VRSliderComponent Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Example demonstrating how to configure a VRSliderComponent's properties and set up an event listener for value changes in a Blueprint Actor. ```cpp UPROPERTY(EditAnywhere, BlueprintReadWrite) class UVRSliderComponent* VolumeSlider; void AMyUI::BeginPlay() { Super::BeginPlay(); if (VolumeSlider) { VolumeSlider->SliderAxis = EVRInteractibleAxis::Axis_X; VolumeSlider->SliderMinPosition = 0.0f; VolumeSlider->SliderMaxPosition = 100.0f; VolumeSlider->bUseSnapPoints = true; VolumeSlider->SnapPointIncrement = 10.0f; VolumeSlider->OnSliderValueChanged.AddDynamic(this, &AMyUI::OnVolumeChanged); } } void AMyUI::OnVolumeChanged(float NewValue) { UE_LOG(LogTemp, Warning, TEXT("Volume: %f"), NewValue * 100.0f); } ``` -------------------------------- ### Get Gripped Objects Info Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Returns an array of detailed grip information for all grips. Use this to get specific details about each grip. ```cpp UFUNCTION(BlueprintPure, Category = "GripMotionController") void GetGrippedObjectsInfo(TArray& GripArray); ``` -------------------------------- ### Custom Grip Script Implementation Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Provides the implementation for the custom grip script, UMyCustomGripScript. Includes constructor, GetWorldTransform, OnGrip, and OnGripTick logic. ```cpp UMyCustomGripScript::UMyCustomGripScript() { // Set default values } bool UMyCustomGripScript::GetWorldTransform_Implementation( UGripMotionControllerComponent* OwningController, float DeltaTime, FVector& WorldPosition, FRotator& WorldRotation, UObject* TargetObject, bool bRenderingThread, bool bSimulatingPhysics ) { if (!OwningController) return false; // Get controller transform WorldPosition = OwningController->GetComponentLocation(); WorldRotation = OwningController->GetComponentRotation(); // Apply auto-rotation if enabled if (bAutoRotate) { CurrentRotationAngle += RotationSpeed * DeltaTime; WorldRotation.Roll += RotationSpeed * DeltaTime; } return true; // Success } void UMyCustomGripScript::OnGrip_Implementation( UGripMotionControllerComponent* OwningController, const FBPActorGripInformation& GripInformation ) { Super::OnGrip_Implementation(OwningController, GripInformation); UE_LOG(LogTemp, Warning, TEXT("Custom grip started!")); CurrentRotationAngle = 0.0f; } void UMyCustomGripScript::OnGripTick_Implementation( UGripMotionControllerComponent* OwningController, const FBPActorGripInformation& GripInformation, float DeltaTime ) { Super::OnGripTick_Implementation(OwningController, GripInformation, DeltaTime); // Per-frame custom logic here } ``` -------------------------------- ### Begin Gesture Capture Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-movement-locomotion.md Starts recording hand motion for gesture recognition. Use this function to initiate the gesture capture process. ```cpp UFUNCTION(BlueprintCallable, Category = "VRGesture") void BeginGestureCapture(FName GestureName); ``` -------------------------------- ### Documentation Navigation Guide Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/00-START-HERE.md This table provides a quick reference for the key documentation files within the VR Expansion Plugin, indicating when to read each file and its primary content. ```markdown | File | When to Read | Content | |------|--------------|---------| | [README.md](README.md) | First | Overview, architecture, concepts | | [INDEX.md](INDEX.md) | Second | Navigation and search guide | | [types.md](types.md) | Reference | All types, enums, structs | | [configuration.md](configuration.md) | Setup | Configuration and settings | | [grip-motion-controller-component.md](api-reference/grip-motion-controller-component.md) | Core feature | Main motion controller API | | [grippable-components.md](api-reference/grippable-components.md) | Core feature | Making objects grippable | | [grip-scripts.md](api-reference/grip-scripts.md) | Advanced | Custom grip behavior | | [interactible-components.md](api-reference/interactible-components.md) | UI | Interactive components | | [vr-base-character.md](api-reference/vr-base-character.md) | Foundation | VR character setup | | [vr-expansion-function-library.md](api-reference/vr-expansion-function-library.md) | Utility | 60+ helper functions | | [vr-movement-locomotion.md](api-reference/vr-movement-locomotion.md) | Features | Movement systems | | [openxr-expansion.md](api-reference/openxr-expansion.md) | Advanced | Hand tracking | ``` -------------------------------- ### Configure GS_Physics Grip Script Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Example of how to create and configure a GS_Physics grip script instance in C++, setting custom physics properties like stiffness, damping, and break distance. ```cpp UGS_Physics* PhysicsScript = NewObject(); PhysicsScript->Stiffness = 2000.0f; PhysicsScript->Damping = 300.0f; PhysicsScript->BreakDistance = 150.0f; ``` -------------------------------- ### Get Grip by ID Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets detailed grip information by grip ID. Use this to retrieve information for a specific grip. ```cpp UFUNCTION(BlueprintPure, Category = "GripMotionController") bool GetGripByID(uint8 GripID, FBPActorGripInformation& OutGripInformation); ``` -------------------------------- ### Create a Grippable Object Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Example of creating a custom grippable weapon by inheriting from AGrippableStaticMeshActor. This demonstrates implementing core VR grip interface functions like GetPrimaryGripType, AllowsMultipleGrips, OnGrip, and OnGripRelease. ```cpp // In BP or C++ class AMyGrippableWeapon : public AGrippableStaticMeshActor { GENERATED_BODY() public: AMyGrippableWeapon(); virtual void BeginPlay() override; // IVRGripInterface implementation virtual EGripCollisionType GetPrimaryGripType_Implementation(bool bIsSlot) override { return EGripCollisionType::ManipulationGrip; } virtual bool AllowsMultipleGrips_Implementation() override { return true; // Allow two-handed grip } virtual void OnGrip_Implementation( UGripMotionControllerComponent* GrippingController, const FBPActorGripInformation& GripInformation) override { UE_LOG(LogTemp, Warning, TEXT("Weapon gripped!")); } virtual void OnGripRelease_Implementation( UGripMotionControllerComponent* ReleasingController, const FBPActorGripInformation& GripInformation, bool bWasSocketed = false) override { UE_LOG(LogTemp, Warning, TEXT("Weapon released!")); } }; ``` -------------------------------- ### Setup VR Character with Motion Controllers Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/INDEX.md Set up a VR character by inheriting from AVRBaseCharacter. Motion controllers are automatically created and can be accessed via specific functions. ```cpp class AMyVRChar : public AVRBaseCharacter {}; // Motion controllers auto-created // Access: GetLeftMotionController(), GetRightMotionController() ``` -------------------------------- ### Implement IVRGripInterface for a Grippable Object Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/INDEX.md Implement the IVRGripInterface to make an actor grippable by motion controllers. This example shows the basic structure for defining grip behavior. ```cpp class AMyObject : public AActor, public IVRGripInterface { virtual EGripCollisionType GetPrimaryGripType_Implementation(...) { return EGripCollisionType::ManipulationGrip; } }; // Grip it: Controller->GripObject(MyObject); ``` -------------------------------- ### Custom Grip Script Header Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Defines a custom grip script, UMyCustomGripScript, inheriting from UVRGripScriptBase. Includes configurable properties and overrides for core grip behavior functions. ```cpp #pragma once #include "CoreMinimal.h" #include "GripScripts/VRGripScriptBase.h" #include "MyCustomGripScript.generated.h" UCLASS(Blueprintable, EditInlineNew) class MYPROJECT_API UMyCustomGripScript : public UVRGripScriptBase { GENERATED_BODY() public: UMyCustomGripScript(); // Configuration UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CustomGrip") float RotationSpeed = 45.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CustomGrip") bool bAutoRotate = true; // Core behavior virtual bool GetWorldTransform_Implementation( UGripMotionControllerComponent* OwningController, float DeltaTime, FVector& WorldPosition, FRotator& WorldRotation, UObject* TargetObject, bool bRenderingThread, bool bSimulatingPhysics ) override; virtual void OnGrip_Implementation( UGripMotionControllerComponent* OwningController, const FBPActorGripInformation& GripInformation ) override; virtual void OnGripTick_Implementation( UGripMotionControllerComponent* OwningController, const FBPActorGripInformation& GripInformation, float DeltaTime ) override; private: float CurrentRotationAngle = 0.0f; }; ``` -------------------------------- ### Get Advanced Grip Settings Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Retrieves advanced physics and behavior settings for grips. Refer to the types.md documentation for detailed explanations of these settings. ```cpp UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "VRGripInterface") FBPAdvGripSettings AdvancedGripSettings(); ``` -------------------------------- ### ARailcar::StartRide Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-movement-locomotion.md Starts the railcar ride by setting the path progress to 0 and enabling automatic progress. ```APIDOC ## ARailcar::StartRide ### Description Starts the railcar ride along the spline path. ### Method BlueprintCallable ### Example ```cpp UFUNCTION(BlueprintCallable, Category = "Railcar") void StartRide(); ``` ``` -------------------------------- ### Convert Grip Pair to Motion Controller Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-expansion-function-library.md Extracts the UGripMotionControllerComponent from an FBPGripPair structure. Use this to get a reference to the controller associated with a grip. ```cpp UFUNCTION(BlueprintPure, meta = (DisplayName = "ToController (FBPGripPair)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary") static UGripMotionControllerComponent* Conv_GripPairToMotionController(const FBPGripPair& GripPair); ``` -------------------------------- ### Hand Gesture Detection Example Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/openxr-expansion.md Demonstrates how to detect common hand gestures like open hands, pointing, and finger curls using OpenXR skeletal data. Requires a valid HandPoseComponent and utilizes helper functions from UOpenXRExpansionFunctionLibrary. ```cpp void AMyVRCharacter::CheckHandGestures() { if (!HandPoseComponent) return; FBPOpenXRActionSkeletalData LeftHand = HandPoseComponent->GetLeftHandData(); FBPOpenXRActionSkeletalData RightHand = HandPoseComponent->GetRightHandData(); // Check if both hands are open if (UOpenXRExpansionFunctionLibrary::GetIsHandOpen(LeftHand) && UOpenXRExpansionFunctionLibrary::GetIsHandOpen(RightHand)) { OnBothHandsOpen(); } // Check if right hand is pointing if (UOpenXRExpansionFunctionLibrary::GetIsHandPointingGesture(RightHand)) { FTransform IndexTip = UOpenXRExpansionFunctionLibrary::GetBoneTransform( RightHand, EXRHandJointType::OXR_HAND_JOINT_INDEX_TIP_EXT ); OnPointingWithRight(IndexTip.GetLocation()); } // Check individual finger curls float ThumbCurl = UOpenXRExpansionFunctionLibrary::GetFingerCurl( RightHand, EXRHandJointType::OXR_HAND_JOINT_THUMB_METACARPAL_EXT ); if (ThumbCurl > 0.8f) { OnThumbCurled(); } } ``` -------------------------------- ### Get Grip Stiffness and Damping Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Returns the physics constraint stiffness and damping values for physics-based grips. Tune these values to control the rigidity and responsiveness of the grip. ```cpp UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "VRGripInterface") void GetGripStiffnessAndDamping(float& GripStiffnessOut, float& GripDampingOut); ``` -------------------------------- ### Get Game Viewport Client Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-expansion-function-library.md Retrieves the game viewport client object for the current world context. Useful for accessing viewport-specific information. ```cpp UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions") static UGameViewportClient* GetGameViewportClient(UObject* WorldContextObject); ``` -------------------------------- ### Get Component Velocity Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets the motion controller's current velocity. This is used by physics and thrown objects. ```cpp virtual FVector GetComponentVelocity() const override; ``` -------------------------------- ### Configure Default Engine Startup Settings for VR Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Set up essential engine startup parameters such as fixed frame rate and physics settings. Enable asynchronous physics scenes and forward rendering for VR performance. ```INI [/Script/Engine.Engine] ; Enable input bUseFixedFrameRate=False FixedFrameRate=90 [/Script/Engine.PhysicsSettings] ; VR-friendly physics DefaultGravityZ=-980.0 bEnableAsyncScene=True [/Script/Engine.RendererSettings] ; VR rendering optimizations bUseForwardRendering=True bAllowGlobalClipPlane=True ``` -------------------------------- ### Get Calculated Velocity Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets the calculated velocity for a specific grip. Use this to determine the speed of a gripped object. ```cpp UFUNCTION(BlueprintCallable, Category = "GripMotionController|ComponentVelocity") FVector GetCalculatedVelocity(uint8 GripID); ``` -------------------------------- ### Get Grip Movement Replication Type Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Defines how the movement of a gripped object should be replicated across a network. Choose the appropriate setting for your network synchronization needs. ```cpp UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "VRGripInterface") EGripMovementReplicationSettings GripMovementReplicationType(); ``` -------------------------------- ### Get Pivot Location Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets the current pivot location in world space. Use this to retrieve the current pivot position of the controller. ```cpp UFUNCTION(BlueprintPure, Category = "GripMotionController", meta = (DisplayName = "GetPivotLocation")) FVector GetPivotLocation_BP(); ``` -------------------------------- ### Get Pivot Transform Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets the current pivot transform in world space. Use this to retrieve the current pivot point of the controller. ```cpp UFUNCTION(BlueprintPure, Category = "GripMotionController", meta = (DisplayName = "GetPivotTransform")) FTransform GetPivotTransform_BP(); ``` -------------------------------- ### Get Gripped Object by ID Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-motion-controller-component.md Gets the gripped object by grip ID. Use this to retrieve the UObject associated with a specific grip ID. ```cpp UFUNCTION(BlueprintPure, Category = "GripMotionController") bool GetGrippedObjectByID(uint8 GripID, UObject*& OutObject); ``` -------------------------------- ### Grip Request and Replication Flow Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/README.md Illustrates the sequence of events when a controller grips an object, from the initial request to network replication. This flow highlights the interaction between the controller, the grippable actor implementing IVRGripInterface, the grip script, and the server's replication process. ```UnrealScript Controller.GripObject(MyActor) → MyActor implements IVRGripInterface → GripScript determines behavior → Server replicates to clients → Controller holds grip in GrippedObjects array ``` -------------------------------- ### Implement Per-Object Grip Scripts Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Implement the IVRGripInterface to provide custom grip scripts for specific objects. This allows for unique interaction behaviors per object. ```cpp bool AMyGrippableObject::GetGripScripts_Implementation( TArray& ArrayReference ) { // Create and configure grip script UGS_Physics* PhysicsScript = NewObject(this); PhysicsScript->Stiffness = 2000.0f; PhysicsScript->Damping = 300.0f; ArrayReference.Add(PhysicsScript); return true; } ``` -------------------------------- ### Creating a Custom Grip Script Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/README.md Extend UVRGripScriptBase to define custom grip behaviors. Override GetWorldTransform to control the object's position and rotation while gripped. ```cpp // 1. Extend UVRGripScriptBase UCLASS(Blueprintable) class UMyGripScript : public UVRGripScriptBase { virtual bool GetWorldTransform_Implementation(...) override { // Calculate desired position/rotation WorldPosition = Controller->GetComponentLocation(); WorldRotation = Controller->GetComponentRotation(); return true; } }; // 2. Assign to gripped object GrippedObject->GetGripScripts(Scripts); Scripts.Add(NewObject()); ``` -------------------------------- ### GetCameraRotation Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Gets the current rotation of the character's camera (HMD). ```APIDOC ## GetCameraRotation ### Description Get current camera rotation. ### Method UFUNCTION(BlueprintPure) ### Returns - **FRotator**: The rotation of the camera. ``` -------------------------------- ### GetCameraLocation Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Gets the current world-space location of the character's camera (HMD). ```APIDOC ## GetCameraLocation ### Description Get current camera (HMD) location in world space. ### Method UFUNCTION(BlueprintPure) ### Returns - **FVector**: The world-space location of the camera. ``` -------------------------------- ### Get Character Half Height Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves the current capsule half-height of the character. ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter") float GetCharacterHalfHeight(); ``` -------------------------------- ### Project File Structure Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/00-START-HERE.md This markdown file outlines the organization of the VR Expansion Plugin's documentation, detailing the purpose of each file and its location within the project. ```markdown ``` /output/ ├── 00-START-HERE.md ← You are here ├── INDEX.md ← Navigation guide and index ├── README.md ← Overview and quick start ├── types.md ← All enums, structs, types ├── configuration.md ← Settings and configuration └── api-reference/ ├── grip-motion-controller-component.md ← Core gripping system ├── grippable-components.md ← Objects that can be gripped ├── grip-scripts.md ← Grip behavior scripting ├── interactible-components.md ← Buttons, sliders, dials, etc ├── vr-base-character.md ← VR character implementation ├── vr-expansion-function-library.md ← Utility functions (60+) ├── vr-movement-locomotion.md ← Movement and locomotion └── openxr-expansion.md ← Hand skeleton tracking ``` ``` -------------------------------- ### Set Grip Movement Replication Settings Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Configure network replication behavior for grippable objects. Use ForceClientSideMovement for responsiveness and NotWhenCollidingOrDoubleGripping for late updates to balance performance and accuracy. ```C++ // On grippable object EGripMovementReplicationSettings ReplicationMode = EGripMovementReplicationSettings::ForceClientSideMovement; EGripLateUpdateSettings LateUpdateMode = EGripLateUpdateSettings::NotWhenCollidingOrDoubleGripping; ``` -------------------------------- ### Configure Grip Motion Controller Component Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Set up the GripMotionControllerComponent by defining its hand, motion source, and tracking/smoothing settings. This is typically done within an actor's Blueprint. ```Blueprint MyVRCharacter ├─ Capsule ├─ Mesh ├─ Camera ├─ LeftMotionController (GripMotionControllerComponent) │ ├─ bSmoothHandTracking: True │ ├─ EuroSmoothingParams: (0.9, 1.0, 0.007) │ └─ bOffsetByControllerProfile: True └─ RightMotionController (GripMotionControllerComponent) ├─ bSmoothHandTracking: True ├─ EuroSmoothingParams: (0.9, 1.0, 0.007) └─ bOffsetByControllerProfile: True ``` -------------------------------- ### Get Camera Rotation Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves the current rotation of the character's camera (HMD). ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter") FRotator GetCameraRotation(); ``` -------------------------------- ### UVRGripScriptBase Configuration Methods Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grip-scripts.md Configuration methods that control how and when grip updates occur, and how movement is replicated. ```APIDOC ## UVRGripScriptBase::GetLateUpdateSetting ### Description Returns when the gripped object should be repositioned. Options include RenderingThread, AlwaysUpdate, DontUpdate, and NotWhenCollidingOrDoubleGripping. ### Method BlueprintNativeEvent, BlueprintCallable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **OwningController** (UGripMotionControllerComponent*) - Controller holding the grip - **GripInformation** (const FBPActorGripInformation&) - Information about the grip ### Request Example None ### Response #### Success Response - **Return Value** (EGripLateUpdateSettings) - The late update setting for the grip #### Response Example None ``` ```APIDOC ## UVRGripScriptBase::GetMovementReplicationSetting ### Description Returns the movement replication setting, such as ClientSide or ServerDriven. ### Method BlueprintNativeEvent, BlueprintCallable ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **OwningController** (UGripMotionControllerComponent*) - Controller holding the grip - **GripInformation** (const FBPActorGripInformation&) - Information about the grip ### Request Example None ### Response #### Success Response - **Return Value** (EGripMovementReplicationSettings) - The movement replication setting for the grip #### Response Example None ``` -------------------------------- ### Get Lever Value Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Retrieves the current position of the lever, ranging from -1.0 to 1.0. ```cpp UFUNCTION(BlueprintPure, Category = "VRLeverComponent") float GetLeverValue(); ``` -------------------------------- ### Get Dial Value Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Retrieves the current normalized value of the dial (0.0 to 1.0). ```cpp UFUNCTION(BlueprintPure, Category = "VRDialComponent") float GetDialValue(); ``` -------------------------------- ### UVRPathFollowingComponent::GetPathProgress Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-movement-locomotion.md Gets the character's current position along the spline path. ```APIDOC ## UVRPathFollowingComponent::GetPathProgress ### Description Get current position along path. ### Method BlueprintPure ### Return Value - **float** - The current progress along the path (0.0 to 1.0). ### Example ```cpp UFUNCTION(BlueprintPure, Category = "VRPathFollowing") float GetPathProgress(); ``` ``` -------------------------------- ### Accessing and Modifying Global VR Settings Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Demonstrates how to retrieve and modify global VR settings, such as grip stiffness, at runtime using C++. ```cpp UVRGlobalSettings* Settings = GetMutableDefault(); Settings->DefaultGripStiffness = 2000.0f; ``` -------------------------------- ### Get Secondary Grip Type Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Returns the behavior for secondary grips, used in two-handed interactions. ```cpp UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "VRGripInterface") ESecondaryGripType SecondaryGripType(); ``` -------------------------------- ### Get Camera Location Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves the current world-space location of the character's camera (HMD). ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter") FVector GetCameraLocation(); ``` -------------------------------- ### UHandSocketComponent Methods and Properties Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Defines a socket for hand alignment and provides methods to get and set its transform. ```APIDOC ## Component: UHandSocketComponent Source: `VRExpansionPlugin/Source/VRExpansionPlugin/Public/Grippables/HandSocketComponent.h` Base: `USceneComponent` ### Overview Defines a socket (attachment point) where a hand can align when gripping. Allows precise hand positioning relative to gripped objects. ### Key Properties | Property | Type | Default | Description | |---|---|---|---| | `HandSocketType` | EHandSocketType | EHS_PrimaryHand | Primary or secondary hand socket | | `TargetGripType` | EGripCollisionType | ManipulationGrip | Socket's grip type | | `AlignmentTransform` | FTransform | Identity | Transform for hand alignment | | `bUseWithCustomGripScripts` | bool | true | Allow custom grip scripts to use this | ### Methods #### GetSocketWorldTransform ```cpp UFUNCTION(BlueprintPure, Category = "HandSocket") FTransform GetSocketWorldTransform(); ``` Gets socket transform in world space. #### SetSocketTransform ```cpp UFUNCTION(BlueprintCallable, Category = "HandSocket") void SetSocketTransform(const FTransform& NewTransform); ``` Sets socket transform in world space. ``` -------------------------------- ### Create a Custom Grip Script Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/INDEX.md Create a custom grip script by inheriting from UVRGripScriptBase to define specific object behavior when gripped. Override GetWorldTransform to control the object's position. ```cpp class UMyGripScript : public UVRGripScriptBase { virtual bool GetWorldTransform_Implementation(...) { // Return desired object position } }; ``` -------------------------------- ### Get Right Motion Controller Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves a pointer to the character's right motion controller component. ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter|Gripping") UGripMotionControllerComponent* GetRightMotionController(); ``` -------------------------------- ### Get Left Motion Controller Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves a pointer to the character's left motion controller component. ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter|Gripping") UGripMotionControllerComponent* GetLeftMotionController(); ``` -------------------------------- ### Get Seated Information Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Retrieves detailed information about the character's current seated mode state. ```cpp UFUNCTION(BlueprintPure, Category = "VRBaseCharacter|Seated") FVRSeatedCharacterInfo GetSeatedInformation(); ``` -------------------------------- ### Configure VR Character Settings Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Sets up motion controller smoothing and grip scripts, along with character movement parameters and network update frequency. Use this to fine-tune VR gameplay mechanics. ```cpp void AMyVRCharacter::SetupVRConfiguration() { // Motion controller setup if (UGripMotionControllerComponent* LeftController = GetLeftMotionController()) { LeftController->bSmoothHandTracking = true; LeftController->bSmoothWithEuroLowPassFunction = true; LeftController->EuroSmoothingParams.MinCutoff = 0.9; LeftController->DefaultGripScriptClass = UGS_Physics::StaticClass(); } // Movement setup if (UVRBaseCharacterMovementComponent* MovComp = Cast(GetCharacterMovement())) { MovComp->MaxWalkSpeed = 600.0f; MovComp->bUseControllerRelativeMovement = true; } // Network replication NetUpdateFrequency = 120.0f; MinNetUpdateFrequency = 30.0f; } ``` -------------------------------- ### Setting Up VR Character Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Demonstrates how to set up a custom VR character by inheriting from AVRBaseCharacter. Includes configuration of movement component and capsule height for standing and seated modes. ```cpp // Header UCLASS() class MYPROJECT_API AMyVRCharacter : public AVRBaseCharacter { GENERATED_BODY() public: AMyVRCharacter(); virtual void BeginPlay() override; virtual void Tick(float DeltaTime) override; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR") float StandingCapsuleHeight = 88.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR") float SeatedCapsuleHeight = 40.0f; UFUNCTION(BlueprintCallable, Category = "VR") void EnterSeat(USceneComponent* SeatComponent); UFUNCTION(BlueprintCallable, Category = "VR") void ExitSeat(); }; // Implementation AMyVRCharacter::AMyVRCharacter() { PrimaryActorTick.bCanEverTick = true; bUseControllerRotationPitch = false; bUseControllerRotationYaw = false; bUseControllerRotationRoll = false; } void AMyVRCharacter::BeginPlay() { Super::BeginPlay(); // Configure movement if (UVRBaseCharacterMovementComponent* VRMoveComp = Cast(GetCharacterMovement())) { VRMoveComp->MaxWalkSpeed = 600.0f; VRMoveComp->bUseControllerRelativeMovement = true; } // Set initial capsule height SetCharacterHalfHeight(StandingCapsuleHeight); } void AMyVRCharacter::EnterSeat(USceneComponent* SeatComponent) { SetSeatedMode( SeatComponent, true, // Use HMD as reference true, // Transition smoothly 50.0f, // Allowed radius 20.0f // Threshold ); SetCharacterHalfHeight(SeatedCapsuleHeight); } void AMyVRCharacter::ExitSeat() { UnSeatedVRCharacter(); SetCharacterHalfHeight(StandingCapsuleHeight); } void AMyVRCharacter::Tick(float DeltaTime) { Super::Tick(DeltaTime); // Handle climbing with hand controllers if (UGripMotionControllerComponent* LeftHand = GetLeftMotionController()) { if (LeftHand->IsGripping()) { if (UVRBaseCharacterMovementComponent* VRMoveComp = Cast(GetCharacterMovement())) { VRMoveComp->SetClimbingMode(true); } } } } ``` -------------------------------- ### Get Teleport Location Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/vr-base-character.md Calculates a valid ground-based teleportation location, optionally adjusting for HMD height. ```cpp UFUNCTION(BlueprintCallable, Category = "VRBaseCharacter") FVector GetTeleportLocation( FVector InTargetLocation, bool bAdjustForHMDHeight = true ); ``` -------------------------------- ### Get Dial Rotation in Degrees Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Returns the current rotation of the dial in degrees, relative to its minimum rotation. ```cpp UFUNCTION(BlueprintPure, Category = "VRDialComponent") float GetDialRotationDegrees(); ``` -------------------------------- ### Motion Controller Component Tracking Settings Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/configuration.md Configure tracking scaling, height limiting, and HMD leashing for the GripMotionControllerComponent. ```ini [/Script/VRExpansionPlugin.GripMotionControllerComponent] ; Tracking scaling bScaleTracking=False TrackingScaler=(X=1.0,Y=1.0,Z=1.0) ; Height limiting bLimitMinHeight=False MinimumHeight=0.0 bLimitMaxHeight=False MaximumHeight=100.0 ; HMD leashing bLeashToHMD=False LeashRange=100.0 ``` -------------------------------- ### Get Slider Value Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/interactible-components.md Retrieves the current value of the slider. Use this to read the slider's state. ```cpp UFUNCTION(BlueprintPure, Category = "VRSliderComponent") float GetSliderValue(); ``` -------------------------------- ### IVRGripInterface Configuration Methods Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Objects implementing IVRGripInterface can configure their gripping behavior through these methods. They control denial of gripping, primary and secondary grip types, late update settings, movement replication, physics stiffness and damping, grip break distance, and whether multiple grips are allowed. ```APIDOC ## IVRGripInterface Configuration Methods ### Deny Gripping - **Description**: Returns true if gripping is currently denied. Default is false (allow gripping). - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: bool - **Parameters**: - **GripInitiator** (UGripMotionControllerComponent*) - Optional - The motion controller component initiating the grip. ### Get Primary Grip Type - **Description**: Returns the collision/interaction type for this grip. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: EGripCollisionType - **Parameters**: - **bIsSlot** (bool) - Required - True if gripping a hand socket slot. ### Secondary Grip Type - **Description**: Returns how secondary grips (two-handed) should behave. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: ESecondaryGripType ### Grip Late Update Setting - **Description**: Returns when the gripped object position should be updated relative to the hand. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: EGripLateUpdateSettings ### Grip Movement Replication Type - **Description**: Returns how grip movement should be replicated over network. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: EGripMovementReplicationSettings ### Get Grip Stiffness and Damping - **Description**: Returns physics constraint stiffness and damping for physics grips. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: void - **Output Parameters**: - **GripStiffnessOut** (float&) - Output: The stiffness of the grip. - **GripDampingOut** (float&) - Output: The damping of the grip. ### Advanced Grip Settings - **Description**: Returns advanced physics and behavior settings. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: FBPAdvGripSettings ### Grip Break Distance - **Description**: Returns the distance at which physics grips should break apart. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: float ### Allows Multiple Grips - **Description**: Returns true if multiple controllers can grip this object simultaneously. - **Method**: BlueprintNativeEvent, BlueprintCallable - **Category**: VRGripInterface - **Return Type**: bool ``` -------------------------------- ### IsHeld Method Source: https://github.com/mordentral/vrexpansionplugin/blob/Master/_autodocs/api-reference/grippable-components.md Gets whether this object is currently gripped and which controllers hold it. Provides information about the grip state. ```cpp UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "VRGripInterface") void IsHeld( TArray& HoldingControllers, bool& bIsHeld ); ```