← Back to all addons

Aiming with Gamepad Right Stick

Posted by Gyvr on Sep 5, 2025 at 6:44 PM

Feature3.0 Verified
🔥 7 💡 3 👏 2

This add-on allows you to aim using a gamepad’s right stick.

All the changes will be made to the PlayerController.cs script.

  1. Anywhere in the OnStart method, add:
GameManager.InputSystem.gameplay.point.performed += OnPoint;
  1. Anywhere in the OnStop method, add:
GameManager.InputSystem.gameplay.point.performed -= OnPoint;
  1. Anywhere under the PlayerController.cs script, add the following method:
private void OnPoint(InputAction.CallbackContext context)
{
    if (!m_castAbilitiesInPointerDirection) return;
    if (context.control.device is Pointer)
    {
        Vector2 pointerPosition = context.ReadValue<Vector2>();
        Vector2 mousePosWorld = Camera.main.ScreenToWorldPoint(pointerPosition);
        Vector2 characterToMouseDir = (mousePosWorld - (Vector2)m_interactionPivot.transform.position).normalized;
        m_subject.SetTargetDirection(characterToMouseDir);
    }
    else
    {
        Vector2 direction = context.ReadValue<Vector2>();
        if (direction.magnitude > 0.2f)
        {
            m_subject.SetTargetDirection(direction.normalized);
        }
    }
}
  1. Find the OnUpdate method and replace it with:
protected override void OnUpdate()
{
    m_interactedThisFrame = false;
    m_interactionTarget = GetInteractibleObject();
    if (!m_castAbilitiesInPointerDirection)
    {
        m_subject.ResetTargetDirection();
    }
}
  1. Find input settings in Assets/Mythril2D/Demo/Settings/PlayerInputActions and double click on it.

  2. under the “Gameplay” action map, find the “Move” action. Copy the “Left Stick [Gamepad]” action and paste it under “Point”.

  3. Click on the newly created action, and edit the “Path” value from “Left Stick [Gamepad]” to “Right Stick [Gamepad]”.

  4. Save the asset (top right of the window)

  5. Enjoy!

💬 Comments (1)

Muted Sep 05, 2025 at 08:28 PM
working perfect and without losing the mouse aim just in case!
❤️ 1

Want to continue the conversation?