**Hey Guys!
**
This should be a fairly straight forward venture, but for the life of me, I just can’t get it to work as it should.
Complex things are by far a LOT easier than the small things!
Anyhoo, I set up a simple input axis for the X and Y of the Right GamePad Stick called LookX/Y respectively.
I binded them like so:
InputComponent->BindAxis("LookY", this, &ACharacterLearningCharacter::LookY);
InputComponent->BindAxis("LookX", this, &ACharacterLearningCharacter::LookX);
Super simple!
Right stick = Mouse movement…
Then I set up the functions which work, but not correctly…
The comments explain whats going on:
void ASSCharacter::LookX(float Value)
{
//Check for controller
if (Controller != NULL)
{
//Get the viewport from the player of the casted controller
FViewport* v = CastChecked<ULocalPlayer>(Cast<APlayerController>(Controller)->Player)->ViewportClient->Viewport; //This works
//Check the pointer
if (v != NULL)
{
//Grab the current X value
int tmpX = v->GetMouseX(); //This works
//Update the value
tmpX = tmpX + Value; //This works
//Set the value
v->SetMouse(tmpX, v->GetMouseY()); //This locks my mouse in position until I focus on the Viewport
//AND, it doesn't update the position at all
//Debug the value just to be sure
if (GEngine != NULL) GEngine->AddOnScreenDebugMessage(-1, 0.001f, FColor::Green, FString::SanitizeFloat(Value));
if (GEngine != NULL) GEngine->AddOnScreenDebugMessage(-1, 0.001f, FColor::Green, FString::FromInt(v->GetMouseY()));
//THE DEBUG SHOWS THE VALUE BEING PASSED IN CORRECTLY, yet, the position won't change.
}//if
}//if
}//LookX
So yea, I don’t know why it’s not working.
When not focused on the viewport and the game is running, even if you move the mouse, it snaps back to the top left of the screen.
However once you manage to click the viewport, the mouse acts as normal, however it won’t be updated via my passed value.
Any ideas or any tips if anyone has encountered this before?
Thanks again guys!
-