VR Camera Without headset

I don’t always have access to my VR headset and I’d like to be able to move around the world using mouse and keyboard. I added Some controls to move the camera via mouse but am having an issue.
AddControllerYawInput behaves correctly and turns my camera left and right, but AddControllerPitchInput does not seem to work. I posted the entire function below.

// Called to bind functionality to input
void AVRCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	PlayerInputComponent->BindAxis("Forward", this, &AVRCharacter::MoveForward);
	PlayerInputComponent->BindAxis("Right", this, &AVRCharacter::MoveRight);

        // AddControllerYawInput works and turns the camera
	PlayerInputComponent->BindAxis("Turn", this, &AVRCharacter::AddControllerYawInput);

        // AddControllerPitchInput does not work
	PlayerInputComponent->BindAxis("LookUp", this, &AVRCharacter::AddControllerPitchInput);
}

I only briefly looked at this but you don’t show all the code?

According to the official UE4 source eg

PlayerInputComponent->BindAxis("Forward", this, &AVRCharacter::MoveForward);

the &AVRCharacter::MoveForward, you should have a function MoveForward which I don’t see here.

ue4 source shows eg

PlayerInputComponent->BindAxis(*MoveForwardAxisName, this, &AArchVisCharacter::MoveForward);
....
void AArchVisCharacter::MoveForward(float Val)
{
.... //code to move forward
}

ue4 source file at ue4 git: /Engine/Plugins/Runtime/ArchVisCharacter/Source/ArchVisCharacter/Private/ArchVisCharacter.cpp

Maybe you’re using the default engine code, I’m not sure. If nothing works, then they may not allow it the way you’re trying and you need to do it differently.

MoveForward and MoveRight are custom functions I made that are handling the player movement. They work with no problems, my issue is with

PlayerInputComponent->BindAxis("LookUp", this, &AVRCharacter::AddControllerPitchInput);

AddControllerPitchInput is a function from the default engine but doesn’t appear to be working or I am not using it properly here

Did you try making an empty function block with just a test code in it for AddControllerPitchInput?

The test code can be a log entry, or some other noise that you can see visibly.

If the function runs then you can fill it in to do what you want. I’m not sure why using the engine version wouldn’t work but if you do a custom one for that then you will surely narrow it down more if not get it working.

It could be too that it works there but when you use the control for it that that part isn’t working unless you already know that part works as well.

I found the solution. I had to set the bUseControllerRotationPitch to true in the BeginPlay() function

// Called when the game starts or when spawned
void AVRCharacter::BeginPlay()
{
	Super::BeginPlay();
	
	bUseControllerRotationPitch = true;
}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms