Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

How Can I Add DeadZone on Bottom of Screen?

Discussion in 'Scripting' started by 1ht1baron, Apr 12, 2018.

  1. 1ht1baron

    1ht1baron

    Joined:
    Aug 15, 2017
    Posts:
    65
    I want to add dead zone on bottom of screen. Buttons must be work. Pink area is deadzone and yellow are is touchable zone. My character can shoot everywhere touching to screen. It detect with this codes:
    Code (CSharp):
    1. return Camera.main.ScreenPointToRay (Input.mousePosition).origin;
    I don't want to shoot and detect mouse position if i touch deadzone or buttons.
    Please help.

     
    Last edited: Apr 12, 2018
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    Should be able to just have an image overlaying that area with the raycat turned on so it blocks. Can set the transparency to 0 if you want it invisible. Then depending on what your touch zone is using, you can check if you are over the "image" gameobject when you touch and don't process that touch.
     
    Lethn likes this.
  3. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,583
    @Brathnann Wouldn't raycast layers also work for this? Might even be simpler.
     
  4. 1ht1baron

    1ht1baron

    Joined:
    Aug 15, 2017
    Posts:
    65
    I forgot to write that my character can shoot everywhere touching to screen. It detect with this codes:
    Code (CSharp):
    1. return Camera.main.ScreenPointToRay (Input.mousePosition).origin;
    I don't want to shoot and detect mouse position if i touch deadzone or buttons.
     
  5. 1ht1baron

    1ht1baron

    Joined:
    Aug 15, 2017
    Posts:
    65
    So, when i touch deadzone or buttons, i want it feels like untouch. Only buttons must work.
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,140
    @Lethn mentioned raycast layers, but I've honestly not used them for this purpose.

    My particular method was about detecting what your touch was over and then ignoring it if it was on a gameobject that was on the UI layer, thus not shooting.

    There are certainly different ways of achieving what you want.