Search Unity

Resolved Disable snap back of a on-screen stick

Discussion in 'Input System' started by Bliggfang, Aug 14, 2022.

  1. Bliggfang

    Bliggfang

    Joined:
    Sep 8, 2021
    Posts:
    9
    Is there a way that a on-screen stick (Unity Input System) doesn't snap back to its original position on pointer up?
     
  2. Bliggfang

    Bliggfang

    Joined:
    Sep 8, 2021
    Posts:
    9
    SOLVED

    Sorry, noob-question! :p

    Just don't use the original OnScreenStick script, but make a copy and adjust OnPointerUp there. Something like this:

    Original:
    Code (CSharp):
    1. public void OnPointerUp(PointerEventData eventData)
    2. {
    3.     ((RectTransform)transform).anchoredPosition = m_StartPos;
    4.     SendValueToControl(Vector2.zero);
    5. }
    Adaption:
    Code (CSharp):
    1. public void OnPointerUp(PointerEventData eventData)
    2. {
    3.     // do nothing
    4. }