Общая информация
Description
VR Player is a game ready class which is inherited from the pawn class. It has a collision and completely diffrent movement which was written from scratch to fit the VR concept. Class has build in player input so no additional setup required(Starting from Unreal Engine 5.2. Older buils such as 4.27 require old input system setup. You can find config file here).
Main features
Advanced Collision
Smooth locomotion
Teleportation
Smooth turn
Snap turn
Footsteps sounds
Avatar option
Climbing
Advanced VR Camera behaviour
Game ready input
Developer mode
Collision and movement
Player collision has an ability to adapt to the player's height and follow the camera during the movement in the real world. Moving in room scale makes collision behave as expected. Collision will not pass through the walls, instead it will react to all obstacles. Down below is the algorithm which shows what plugin function are used to achieve the result.
Algorithm overview
Main Functions
CheckFloor(Only v1.0-1.5)- This function check if a user is standing on the surface or is falling. Function additionally contains statements for walking on ladders and slopes. The function uses two variables which can be adjusted: MaxStepHeight and MaxFloorSlope.
CheckClimbing - This function check if a user is climbing and changes the position of the user according to the hand locations.
UpdateCollisionHeight - This function updates the collision height and sets value to CurrentPlayerHeight.
CheckUpdatePlayerPosition - This function updates the player position in the world space according to the room scale movement, collision etc.
CheckCollisionSeperation -This function check if player's camera requires a separation from collision. For example player might want to lean on the table to grab something. The function uses one variable which can be adjusted: MaxSeperationDist.(This function is disabled when using Avatar).
Hands
Player's hands are actors which are spawned in the BeginPlay function. Hands class can be specified by selecting the right class by changing the variable VR_HandsClass value(Class supposed to be a child class/BP of AVR_Hands).
Look at the AVR_Hands class for setup and more information.
Avatar
There is a AvatarMode variable which allows to switch between HandsOnly and FullBody options.
Settings
AvatarMode types:
HandsOnly
FullBody
DefaultPlayerHeight - The default character height.
AvatarAnimationInstanceClass - Animation instance class which is being used by player class.
If FullBody option is selected there are two things that is need to be done before the usage. DefaultPlayerHeight and AvatarAnimationInstanceClass must be setup. If you want to use your own mesh, you need to reassign asset by making a right click on the character skeletal mesh. Then choose the skeleton which comes with the plugin("SK_Mannequin").
WARNING
MAKE SURE YOU ASSIGNED YOUR OWN MESH OTHERWISE YOU WILL GET ERRORS.
Look at the UVR_AvatarAnimationInstance class for an animation blueprint setup and more information how it works. Also see Unreal Engine Documentation on AnimBlueprints.
Footsteps sounds
There are a variety of footsteps sounds(44 sound files). Sound will play depending on the surface type the player steps on or falls on. Footsteps sound cue can be replaced in FootstepsAudioComponent. See audio component documentation: Basics, C++ API.
To specify frequency of footsteps sounds adjust the StepDistance value inside the class.
Footsteps require the following surface types. These surface types can be added in the UnrealProject\Config\DefaultEngine.ini.
+PhysicalSurfaces=(Type=SurfaceType1,Name="Dirt")
+PhysicalSurfaces=(Type=SurfaceType2,Name="Rock")
+PhysicalSurfaces=(Type=SurfaceType3,Name="Sand")
+PhysicalSurfaces=(Type=SurfaceType4,Name="Water")
+PhysicalSurfaces=(Type=SurfaceType5,Name="Glass")
+PhysicalSurfaces=(Type=SurfaceType6,Name="Cloth")
+PhysicalSurfaces=(Type=SurfaceType7,Name="Metal")
+PhysicalSurfaces=(Type=SurfaceType8,Name="wood")
+PhysicalSurfaces=(Type=SurfaceType9,Name="Grass")
+PhysicalSurfaces=(Type=SurfaceType10,Name="Carpet")
+PhysicalSurfaces=(Type=SurfaceType11,Name="Concreate")
+PhysicalSurfaces=(Type=SurfaceType12,Name="Snow")
+PhysicalSurfaces=(Type=SurfaceType13,Name="Tile")
+PhysicalSurfaces=(Type=SurfaceType14,Name="Asphalt")
+PhysicalSurfaces=(Type=SurfaceType15,Name="Brick")
+PhysicalSurfaces=(Type=SurfaceType16,Name="Cardboard")
+PhysicalSurfaces=(Type=SurfaceType17,Name="Clay")
+PhysicalSurfaces=(Type=SurfaceType18,Name="Plastic")
+PhysicalSurfaces=(Type=SurfaceType19,Name="Electrinics")
+PhysicalSurfaces=(Type=SurfaceType20,Name="Sheetrock")
+PhysicalSurfaces=(Type=SurfaceType21,Name="Plaster")
+PhysicalSurfaces=(Type=SurfaceType22,Name="Leaver")
+PhysicalSurfaces=(Type=SurfaceType23,Name="Blood")
Channel Responses
VR Player and VR Hand reqires addition channel responses.These Channel Responses can be added in the UnrealProject\Config\DefaultEngine.ini.
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="GrabbedObject")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="VR_Hands")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel4,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Door_Parent")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel5,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="VRweapon")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel6,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="NPC")
Enhanced Input
Enhanced Input does not require additional setup. However settings can be adjusted(If plugin was added to the existing project or to the standart VR UE Tamplate, enhanced input might be blocked by other IMCs and IAs files. The solution is to remove other files or add mappings and replace IMCs and IAs inside VR Player input).
Ammo inventory
Optional ammo inventory which is located behind the left shoulder(Similar to the Half-Life:Alyx ammo inventory).
Settings
Ammo - Array which stores the amount of ammo by a caliber(Array index).
Max Ammo - Array which stores the maximum amount of ammo by a caliber(Array index).
Other Settings
Debug mode - Shows the debug traces and all debug information about the player.
Developer Mode - Allows to run in non VR mode (Use in previewing only).
Splash Screen texture - Loading screen texture.
Menu Status - Should be true if player is in the main menu level on start.
In Loading Room - Should be true if player is in the loading room on start.
Max Health - Maximum value of player's health.
Справочник API Blueprint
Public Member Functions | |
| AVR_Player () |
| |
virtual void | OnConstruction (const FTransform &Transform) override |
| |
virtual void | BeginPlay () override |
| |
virtual void | EndPlay (EEndPlayReason::Type EndPlayReason) override |
| |
virtual void | |
| |
virtual void | Tick (float DeltaTime) override |
| |
virtual void | SetupPlayerInputComponent (class UInputComponent *PlayerInputComponent) override |
| |
void | PlayerMeshTick (float DeltaTime) |
| |
bool | CheckHandPtrExist (bool Hand) |
| |
void | OnResetVR () |
| Resets HMD orientation and position in VR. |
| |
void | |
| Grip button pressed (Left Motion controller) |
| |
void | |
| Grip button released (Left Motion controller) |
| |
void | |
| Grip button pressed (Right Motion controller) |
| |
void | |
| Grip button released (Right Motion controller) |
| |
void | GrabActor_Server (bool Hand) |
| |
bool | GrabActor_Server_Validate (bool Hand) |
| |
void | GrabActor_Server_Implementation (bool Hand) |
| |
void | GrabActor_Multycast (bool Hand) |
| |
bool | GrabActor_Multycast_Validate (bool Hand) |
| |
void | GrabActor_Multycast_Implementation (bool Hand) |
| |
void | ReleaseActor_Server (bool Hand) |
| |
bool | ReleaseActor_Server_Validate (bool Hand) |
| |
void | ReleaseActor_Server_Implementation (bool Hand) |
| |
void | ReleaseActor_Multycast (bool Hand) |
| |
bool | ReleaseActor_Multycast_Validate (bool Hand) |
| |
void | ReleaseActor_Multycast_Implementation (bool Hand) |
| |
void | |
| Trigger button pressed (Left Motion controller) |
| |
void | |
| Trigger button released (Left Motion controller) |
| |
void | Index_Press_Server (bool Hand, bool Pressed) |
| |
bool | Index_Press_Server_Validate (bool Hand, bool Pressed) |
| |
void | Index_Press_Server_Implementation (bool Hand, bool Pressed) |
| |
void | Index_Press_Multycast (bool Hand, bool Pressed) |
| |
bool | Index_Press_Multycast_Validate (bool Hand, bool Pressed) |
| |
void | Index_Press_Multycast_Implementation (bool Hand, bool Pressed) |
| |
void | |
| Trigger button touched , used for Oculus (Left Motion controller) |
| |
void | |
| Trigger button untouched , used for Oculus (Left Motion controller) |
| |
void | |
| Trigger button touched , used for Oculus (Right Motion controller) |
| |
void | |
| Trigger button untouched , used for Oculus (Right Motion controller) |
| |
void | |
| Trigger button pressed (Right Motion controller) |
| |
void | |
| Trigger button released (Right Motion controller) |
| |
void | |
| Trigger button pressed (Right Motion controller) |
| |
void | |
| Trigger button pressed (Right Motion controller) |
| |
void | |
| Used for Oculus HMD Indetify when player toches upper buttons. |
| |
void | |
| Used for Oculus HMD Indetify when player untoches upper buttons. |
| |
void | Thumb_Press_Server (bool Hand, bool Pressed) |
| |
bool | Thumb_Press_Server_Validate (bool Hand, bool Pressed) |
| |
void | Thumb_Press_Server_Implementation (bool Hand, bool Pressed) |
| |
void | Thumb_Press_Multycast (bool Hand, bool Pressed) |
| |
bool | Thumb_Press_Multycast_Validate (bool Hand, bool Pressed) |
| |
void | Thumb_Press_Multycast_Implementation (bool Hand, bool Pressed) |
| |
void | |
| Trigger button pressed (Left Motion controller) |
| |
void | |
| Trigger button released (Left Motion controller) |
| |
void | A_Press_Server (bool Hand, bool Pressed) |
| |
bool | A_Press_Server_Validate (bool Hand, bool Pressed) |
| |
void | A_Press_Server_Implementation (bool Hand, bool Pressed) |
| |
void | A_Press_Multycast (bool Hand, bool Pressed) |
| |
bool | A_Press_Multycast_Validate (bool Hand, bool Pressed) |
| |
void | A_Press_Multycast_Implementation (bool Hand, bool Pressed) |
| |
void | A_Press_R () |
| Rightg A Button beeing pressed. |
| |
void | A_Released_R () |
| Rightg A Button beeing released. |
| |
void | A_Press_L () |
| Left A Button beeing pressed. |
| |
void | A_Released_L () |
| Left A Button beeing released. |
| |
void | B_Press_Server (bool Hand, bool Pressed) |
| |
bool | B_Press_Server_Validate (bool Hand, bool Pressed) |
| |
void | B_Press_Server_Implementation (bool Hand, bool Pressed) |
| |
void | B_Press_Multycast (bool Hand, bool Pressed) |
| |
bool | B_Press_Multycast_Validate (bool Hand, bool Pressed) |
| |
void | B_Press_Multycast_Implementation (bool Hand, bool Pressed) |
| |
void | B_Press_R () |
| Rightg b Button beeing pressed. |
| |
void | B_Released_R () |
| Rightg b Button beeing released. |
| |
void | B_Press_L () |
| Left b Button beeing pressed. |
| |
void | B_Released_L () |
| Left b Button beeing released. |
| |
void | |
| Rightg Trackpad beeing Touch. |
| |
void | |
| Rightg Trackpad beeing Untouch. |
| |
void | ThumbsticRightXAxis (const FInputActionValue &Value) |
| Player rotation on right thubmstick. |
| |
void | ThumbsticRightYAxis (const FInputActionValue &Value) |
| Updates camera pitch in Developer Mode and crouch in VR. |
| |
void | ThumbsticLeftXAxis (float Value) |
| Player rotation on right thubmstick. |
| |
void | ThumbsticLeftYAxis (float Value) |
| Updates camera pitch in Developer Mode and crouch in VR. |
| |
void | UpdateMovment (const FInputActionValue &Value) |
| Moves player in direction. |
| |
void | MoveForward (float Value) |
| Used for thumbstick bind. |
| |
void | MoveRight (float Value) |
| Used for thumbstick bind. |
| |
void | RightTriggerAxis (const FInputActionValue &Value) |
| |
void | LeftTriggerAxis (const FInputActionValue &Value) |
| |
void | RightGripAxis (const FInputActionValue &Value) |
| |
void | LeftGripAxis (const FInputActionValue &Value) |
| |
void | ThumbTrackpadAxis (float Value) |
| Used for Weapons hammer(Pistols) |
| |
void | E_Press () |
| E Button press(Works only in Non-VR) |
| |
void | E_Released () |
| E Button released(Works only in Non-VR) |
| |
void | E_Press_Server (bool Released) |
| |
bool | E_Press_Server_Validate (bool Released) |
| |
void | E_Press_Server_Implementation (bool Released) |
| |
void | E_Press_Multycast (bool Released) |
| |
bool | E_Press_Multycast_Validate (bool Released) |
| |
void | E_Press_Multycast_Implementation (bool Released) |
| |
void | Execute_E_Press (bool Released) |
| |
void | |
| |
void | AddHeight () |
| |
void | RemoveHeight () |
| |
void | |
| |
void | |
| |
void | |
| |
FVector | |
| |
void | |
| |
void | |
| Moves GetCapsuleComponent() to the camera by adding world offset. |
| |
void | UpdatePlayerPostion (FVector CurrentCameraPosition, FRotator DeviceRotation) |
| Updates Actor location to the GetCapsuleComponent() location. |
| |
void | UpdateCollisionHeight (FVector DevicePosition) |
| Updates GetCapsuleComponent() Height. |
| |
void | SetMaxSeperationDist (float NewDist) |
| Sets MaxSeperationDist(float) |
| |
void | CameraFade () |
| Fades camera if overlaps objects. |
| |
void | |
| Updates variables , atm only LastCollisionLocation variable. |
| |
void | |
| |
void | ChangeFidelity (uint8 Level) |
| |
FRotator | GetRotationFromInput (float UpAxis, float RightAxis, class AVR_Hands *MotionController) |
| Returns rotation for the teleport. |
| |
void | ExecuteTeleportation (class AVR_Hands *MotionController) |
| Handle Teleportation. |
| |
void | TeleportActor (class AVR_Hands *MotionController) |
| Teleport Player. |
| |
FORCEINLINE UCapsuleComponent * | GetCollision () const |
| |
FORCEINLINE float | GetPlayerMaxHeight () const |
| |
FORCEINLINE float | GetPlayerCurrentHeight () const |
| |
float | GetTargetMS (float DisplayHRZ) |
| |
FVector | |
| |
FVector | |
| |
FVector | GetComponentDirection (class USceneComponent *Component) |
| |
FORCEINLINE class UMotionControllerComponent * | GetLeftMotionController () const |
| |
FORCEINLINE class UMotionControllerComponent * | GetRightMotionController () const |
| |
void | OnCameraCollisionOverlapBegin (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult) |
| On camera GetCapsuleComponent() Overlap begin. |
| |
void | OnCameraCollisionOverlapEnd (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex) |
| On camera GetCapsuleComponent() Overlap end. |
| |
virtual void | OnAmmoBoxOverlap (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult) |
| On Ammo Box Overlap begin. |
| |
virtual void | OnAmmoBoxOverlapEnd (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex) |
| On Ammo Box Overlap Overlap end. |
| |
void | OnCollisionOverlapBegin (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult &SweepResult) |
| On GetCapsuleComponent() Box Overlap begin. |
| |
void | OnCollisionOverlapEnd (class UPrimitiveComponent OverlappedComp, class AActor OtherActor, class UPrimitiveComponent *OtherComp, int32 OtherBodyIndex) |
| On GetCapsuleComponent() Box Overlap Overlap end. |
| |
int | GetAmmo (uint8 &Caliber) |
| Returns ammo of choosen caliber. |
| |
virtual void | |
| Check if object is in the inventory box. |
| |
void | |
| Check when to play step sound. |
| |
void | |
| Check if player has pickup standable object. |
| |
void | |
| |
void | PlayFootstepsSound (bool bHasFallen) |
| Plays footsteps sound. |
| |
void | EnableMovment (bool enable) |
| |
void | |
| |
FORCEINLINE bool | GetPauseMenuOpened () const |
| |
FORCEINLINE bool | GetMenuStatus () const |
| |
FORCEINLINE AVR_Hands * | GetRightHand () const |
| |
FORCEINLINE AVR_Hands * | GetLeftHand () const |
| |
FORCEINLINE int | GetHealth () const |
| |
FORCEINLINE int | GetMaxHealth () const |
| |
FORCEINLINE bool | GetInLoadingRoom () const |
| |
FORCEINLINE TArray< int > | GetAmmoArray () const |
| |
FORCEINLINE bool | IsInLoadingRoom () const |
| |
FORCEINLINE FTransform | GetLeftHandTransform () const |
| |
FORCEINLINE FTransform | GetRightHandTransform () const |
| |
FORCEINLINE FTransform | GetAvatarWorldTransform () const |
| |
FORCEINLINE USkeletalMeshComponent * | GetAvatarMesh () const |
| |
FORCEINLINE FTransform | GetCameraTransform () const |
| |
FORCEINLINE FVector | GetCameraDirection () const |
| |
FORCEINLINE float | GetPlayerSpeed () const |
| |
FORCEINLINE float | GetPlayerDirectionValue () const |
| |
FORCEINLINE EVRAvatarMode | GetAvatarMode () const |
| |
FORCEINLINE FName | GetVRHelmetName () const |
| |
FORCEINLINE bool | IsSprinting () const |
| |
FORCEINLINE bool | CanSptint () const |
| |
FORCEINLINE bool | HasStamina () const |
| |
FORCEINLINE float | GetStamina () const |
| |
float | GetDistanceMoved (FVector CurrentCameraPosition) |
| |
float | GetDistanceRotation (FRotator CurrentCameraRotation) |
| |
FORCEINLINE FVector | GetFloorPoint () const |
| |
float | GetMovementDirection (FTransform CurrentCameraWorldTransform) |
| |
float | PlayVoiceLine (USoundWave *SoundWave) |
| Play voice line. |
| |
void | EnableCameraFadeOnObj (bool Enable) |
| |
void | EnableLoadingRoom (bool Enable) |
| |
void | TeleportPlayerPawn (FVector DestLocation, FRotator DestRotation) |
| |
void | ReciveDamage (int Damage) |
| |
void | Heal (int HealthToAdd) |
| |
void | SetInventory (TArray< TSubclassOf< class AActor > > InventoryActors, TArray< UStaticMesh * > InventoryMeshes, TArray< int > NewAmmo) |
| |
void | SetUserMode (bool VRMode) |
| |
void | SendUserMode_Server (APawn *Player, bool VRMode) |
| |
bool | SendUserMode_Server_Validate (APawn *Player, bool VRMode) |
| |
void | SendUserMode_Server_Implementation (APawn *Player, bool VRMode) |
| |
void | SendUserMode_Multicast (APawn *Player, bool VRMode) |
| |
bool | SendUserMode_Multicast_Validate (APawn *Player, bool VRMode) |
| |
void | SendUserMode_Multicast_Implementation (APawn *Player, bool VRMode) |
|
Public Attributes | |
FVector | |
| |
bool | |
| |
TSubclassOf< class AActor > | |
|
Protected Attributes | |
USceneComponent * | |
| Default scene root. |
| |
USceneComponent * | |
| Players camera scene root. |
| |
USceneComponent * | |
| |
| Players camera. |
| |
class USkeletalMeshComponent * | |
| Players GetCapsuleComponent() |
| |
USphereComponent * | |
| Players camera Collision. |
| |
UBoxComponent * | |
| Ammo box in which player can put ammo. |
| |
UAudioComponent * | |
| |
UAudioComponent * | |
| |
| |
| |
UChildActorComponent * | |
| |
UChildActorComponent * | |
| |
UPhysicsHandleComponent * | |
| |
| Left Motion Controller. |
| |
| Right Motion Controller ///. |
| |
USoundCue * | |
| |
USoundCue * | |
| |
class UInputMappingContext * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * | |
| |
class UInputAction * |