Problem Touch Screen Button - Event Trigger (Pointer Enter)

Hello!
I’m developing a 2D game for mobile.

I created a Sensitive button touch for the character walk right by using Canvas + Event Trigger (“Pointer Enter” to walk and “Pointer Exit” to stop walking).

When compile and test cell in my script works correctly, but I have a nasty problem.

Pressing the first button the Event Trigger “Pointer Enter” is triggered, but when shooting the finger from the screen the “Pointer Exit” is not triggered and the character keeps walking :frowning:

But if I press the button a second time and take the finger from the screen the “Pointer Exit” will be triggered correctly in version 5.2 of Unity worked right when updated to 5.3.1 stopped working, I’m thinking it’s bug.

Follows my movement script.

public class Player: MonoBehaviour
{
    public GameObject player;
    public Animator animator;
    private bool isMove;
    void Start ()
    {
        isMove = false;
    }
    void Update()
    {
        if (isMove == true)
        {
            player.transform.Translate(Vector2.right * 2f * Time.deltaTime);
        }
    }
    public void moveLeft() //Event Trigger (Pointer Enter)
    {
        isMove = true;
    }
    public void touchOff() // Event Trigger (Pointer Exit)
    {
        isMove = false;
    }
}

REMARK!

When retreat the finger Pointer Exit is triggered yes, but character keeps going because I do not know.

Thanks.

PROBLEM SOLVED!

Within “EventSystem” added “Touch Input Module” Simply check the flag “Force Module Active” :smile:

3 Likes

thanks this solved my touch input issue :), i removed standaloneInputModule, it works correct.

1 Like

omg! Thank you for posting this …I was about to start my typical 6 hours debug routine

Touch Input Module is depreciated. It is now handled by the StandaloneInputModule.

1 Like