I don't receive player mouse inputs until I click

I have a pawn, Cannon.cpp, which received mouse Y to rotate. This worked fine until I decided to add a custom cursor.

I have added custom cursor following this: custom cursor

And so I can see the cursor I followed this one: see cursor

After these steps, I have stopped to receive player 0 mouse inputs, unless I click the stage. While I have the mouse button pressed I start receiving mouse inputs and my cannon rotate, but I’m not able to rotate the cannon again if I release the mouse.

Thank for you help. Hope this isn’t a duplicate post i didn’t find nothing similar but looks like a common issue.

Hi Ilunpea,

When you enable ‘Show Mouse Cursor’, you stop sending input events to the actors and return focus to the user. This is typically the desired behavior, since the world space rotation of your actor wouldn’t align very well to the screen space movement of your cursor. If you would like to elaborate on what you’re trying to achieve, I’ll see if I can come up with a good solution for you.

Best,

Cody

Thanks for you answer.

Is a easy task, the cannon must loock always to cursor, as the images below:

To do this I started getting mouse Y inputs but after added custom cursor I only receive them when I click.

Edit: It seems that I actually receive the inputs, but unless I press any mouse button I receive "AxisValue=0.0"

Thanks for the clarification. I’ve recreated a similar setup and I’m still receiving the inputs. Could you share the Cannon actor files with me, along with any details on how you set up your input bindings? I’d be happy to take a look and see if I can find out what’s going on.

thanks ^^

In case my edit have not been seeing because the images I’ll put it again here:
"It seems that I actually receive the inputs, but unless I press any mouse button I receive “AxisValue=0.0"”

And my cannon code is:

#include "FortressDefense.h"
#include "Cannon.h"


// Sets default values
ACannon::ACannon()
{
	[...]

	// Take control of the default player
	AutoPossessPlayer = EAutoReceiveInput::Player0;
}

[...]

// Called to bind functionality to input
void ACannon::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	Super::SetupPlayerInputComponent(InputComponent);

	 [...]

	InputComponent->BindAxis("RotateCannon", this, &ACannon::Rotate);

}

void ACannon::Rotate(float AxisValue) {
	FRotator NewRotation = CannonSprite->GetComponentRotation();
	NewRotation.Pitch += AxisValue;
	CannonSprite->SetRelativeRotation(NewRotation);
}

It looks like using ‘Show Mouse Cursor’ is causing you to lose focus of the game window, which is expected behavior (but problematic in your case). One workaround would be to keep the cursor hidden, and add your cursor widget to the viewport normally. You can then get the mouse position and move your cursor widget to that position in the viewport. Since the viewport will never lose focus, you should continue to receive your input events.

1 Like