Hello there.
I’ve been making a script that listens to input from the right stick of the gamepad in order to indicate the direction in which the character will shoot within a radius from the center of the screen.
private const float RADIUS_MAX_MULTIPLIER = 0.85f;
...
[UsedImplicitly]
public void SetDirection(Vector2 direction) {
var halfWidth = Screen.width / 2;
var halfHeight = Screen.height / 2;
var centerPosition = new Vector2Int(halfWidth, halfHeight);
var radius = Math.Min(halfWidth, halfHeight) * RADIUS_MAX_MULTIPLIER;
Mouse.current.WarpCursorPosition(centerPosition + direction * radius);
}
The character has a separate script that looks at the mouse position in Update()
in order to direct the weapon in the direction of the cursor.
I also have a small script that looks at the last input device to change the icons on the hotkey tooltips.
My problem is that calling the last line triggers the mouse as the last input device. I downloaded the “Gamepad Mouse Cursor” sample in the package manager to check how the cursor movement was done for the gamepad, but it is not what I need.
Is there any way to indicate in the code that the cursor position change was caused by the Gamepad
device?