VR Expansion Plugin

I made some onward style movement in c++ just the other day,
Maybe you can translate something similar to blueprint.
Just figured id share here seeing as we were talking about trackpad movement :slight_smile:

Thanks again for the awesome plugin :slight_smile:


// Move forward/back
void AProtonCharacter_VR::MoveForward(float Val)
{
	if (LeftMotionController && Val != 0.f)
	{

		//note: i tend to actually grab a bunch of info like  during tick. put here for convenience of sharing...
		if (LeftMotionController && VRReplicatedCamera) {
			LeftHandCurrentPosistion = LeftMotionController->RelativeLocation - VRReplicatedCamera->RelativeLocation;
		}

		//rotation/direction is from rotation of controller
		//you still need to deal with actor/control rotation in your project
		// is just to generate movment :)
		const FRotator Rotation = LeftMotionController->GetComponentRotation();
		const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);

		//FORWARD is scaled by distance of controller from camera
		if (LeftHandCurrentPosistion.Size2D() >= 10.f && Val > 0.f) {
			const float TrackpadMoveScaled = TrackpadMoveScale * LeftHandCurrentPosistion.Size2D();
			float NewVal = Val * TrackpadMoveScaled;
			AddMovementInput(Direction, NewVal);
		}
		//BACKWARD is not scaled from camera
		//and is nerfed down to 0.25, walking backward in vr sucks....
		if (Val < 0.f) {
			float NewVal = Val * 0.25f;
			AddMovementInput(Direction, NewVal);
		}
	}
}

// Move left/right
void AProtonCharacter_VR::MoveRight(float Val)
{
	if (Val != 0.f && VRRootReference)
	{
		const FVector Direction = VRRootReference->GetVRRightVector();
		//strafing in vr also sucks, so is nerfed to 0.25...
		float NewVal = Val * 0.25f;
		AddMovementInput(Direction, NewVal);
	}
}

Then you can just assign the axis in your project settings, and pass through to your character from your pc as per usual…