Mobile: How Can I "clean" the player target just touching in any part of screen unless the buttons

Hi!

I have the line

player.target = null;

but I’ve tryed put it in my plataform (this object fills the screen) and thats works with onmousedown, but it doesn’t work if I test with mobile (android) someone help me plz? :frowning:

You will need to provide a lot more detailed information than that to get useful help. Look into how to file a bug report. It starts with:

  1. what you’re trying to do
  2. what code you have tried (use code formatting)
  3. what you expect it to do
  4. what it is actually doing
  5. what debugging steps you have tried so far.

Oh… Sorry ^.^

Let’s Start:

(1)I have a script EnemyScript where there is the code(2):

    public void OnMouseDown()
    {
        player.GetComponent<PlayerMovement>().target = this.gameObject;
        gameManagement.enemieWasClicked = true;
    }

When a enemy is the target’s player, the skills are directed to the enemy “selected”. To select the enemy, I click on the enemy and it works well. Now (3) I want to deselect the enemy when I touching in any part of screen (unless the buttons)… How can I do this to work in mobile? Because I created a script named PlatformScript and used this on that

    public void OnMouseDown()
    {
        player.GetComponent<PlayerMovement>().target = null;
        gameManagement.enemieWasClicked = false;
    }

and in each UI a used the MouseOnUi script, where:

    public void OnPointerEnter(PointerEventData eventData)
    {
        gameManagement.pointerIsOnUi = true;
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        gameManagement.pointerIsOnUi = false;
    }

**(4)**on PC works well, but on mobile (5) don’t. When I used joystick or the skill button (both UIs) doesn’t work and I don’t know why… I guesss its because “OnPointerEnter” its not for touch… I don’t know how transform to “touch” over there…