Skip to content
Tomura edited this page Dec 21, 2021 · 13 revisions

Preface

In general as long as your character inherits from TVRCharacter you are safe. So you are free to do your own implementations of gripping, routing inputs to what ever is gripped, etc. The important part is the your gripping logic conforms to the way VRExpansion intends you to do it, so that grip events are triggered, and that grip information is valid.

Using Sample impelementations of Input Actions

In order to use the projects functionality you need to create a Character Class that inherits from TVRCharacter. If you'd like to use the already implemented actions, override the SetupPlayerInputComponent method and bind inputs accordingly. Here is a C++ example how it is setup in my case.

This API is intended to stay and you will benefit from any improvements like multiplayer support down the line if you keep using it.

void ATacticalVRCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);

    PlayerInputComponent->BindAxis(FName("ContinuousTurn_X"), this, &ATacticalVRCharacter::OnAxisTurnX);
	
    PlayerInputComponent->BindAxis(FName("Move_Y"), this, &ATacticalVRCharacter::OnAxisMoveY);
    PlayerInputComponent->BindAxis(FName("Move_X"), this, &ATacticalVRCharacter::OnAxisMoveX);
	
    PlayerInputComponent->BindAxis(FName("TriggerAxis_R"), this, &ATacticalVRCharacter::OnTriggerAxisR);
    PlayerInputComponent->BindAxis(FName("TriggerAxis_L"), this, &ATacticalVRCharacter::OnTriggerAxisL);
	
    PlayerInputComponent->BindAction(FName("MagRelease_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnMagReleasePressed_Right);
    PlayerInputComponent->BindAction(FName("MagRelease_R"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnMagReleaseReleased_Right);
    PlayerInputComponent->BindAction(FName("MagRelease_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnMagReleasePressed_Left);
    PlayerInputComponent->BindAction(FName("MagRelease_L"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnMagReleaseReleased_Left);
    
    PlayerInputComponent->BindAction(FName("BoltRelease_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnBoltReleasePressed_Right);
    PlayerInputComponent->BindAction(FName("BoltRelease_R"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnBoltReleaseReleased_Right);
    PlayerInputComponent->BindAction(FName("BoltRelease_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnBoltReleasePressed_Left);
    PlayerInputComponent->BindAction(FName("BoltRelease_L"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnBoltReleaseReleased_Left);
    
    PlayerInputComponent->BindAction(FName("CycleFireMode_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnCycleFireMode_Right);
    PlayerInputComponent->BindAction(FName("CycleFireMode_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnCycleFireMode_Left);
    
    PlayerInputComponent->BindAction(FName("UseOrGrabSmall_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnUseOrGrabSmallLeft);
    PlayerInputComponent->BindAction(FName("UseOrGrabSmall_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnUseOrGrabSmallRight);
    PlayerInputComponent->BindAction(FName("UseOrGrabSmall_L"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnStopUseOrGrabSmallLeft);
    PlayerInputComponent->BindAction(FName("UseOrGrabSmall_R"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnStopUseOrGrabSmallRight);
    
    PlayerInputComponent->BindAction(FName("GrabLarge_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnGrabLargeLeft);
    PlayerInputComponent->BindAction(FName("GrabLarge_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnGrabLargeRight);
    PlayerInputComponent->BindAction(FName("GrabLarge_L"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnStopGrabLargeLeft);
    PlayerInputComponent->BindAction(FName("GrabLarge_R"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnStopGrabLargeRight);
	
    PlayerInputComponent->BindAction(FName("TriggerTouch_R"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnTriggerTouchRight);
    PlayerInputComponent->BindAction(FName("TriggerTouch_L"), EInputEvent::IE_Pressed, this, &ATacticalVRCharacter::OnTriggerTouchLeft);
    PlayerInputComponent->BindAction(FName("TriggerTouch_R"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnTriggerReleaseRight);
    PlayerInputComponent->BindAction(FName("TriggerTouch_L"), EInputEvent::IE_Released, this, &ATacticalVRCharacter::OnTriggerReleaseLeft);
}

All the referenced functions are also exposed to blueprint, so you can also do it in your own character blueprint that inherits from TVRCharacter.

Clone this wiki locally