Game Object as Touch Trigger

Hello!

I am working on a game for tablets and am trying to make good use out of the touch screen. Right now the goal is to touch the model and make it sneeze. I have succeeded in getting the scripts for this to work but it works if you touch anywhere on the screen. This wouldn’t be such a problem except I have a GUI menu that needs to be touchable as well, and right now my scripts for the animation&audio have overridden the GUI. Is there a way to make the character model a touch trigger, so that the rest of the screen doesn’t react with a touch?

Here’s my current code:

{
    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
		animation.Play("sneeze"); 
}

I have played around with adding Touch.position (doesn’t recognize it); I have played with adding var Char : GameObject and different variations of Char.TouchPhase.Began, Char = TouchPhase.Began, etc. I have looked at the forums but I haven’t seen this problem presented quite this way… I would appreciate some help!

The best you can do is to use layers, raycast your touches and then limit the area and targets by creating a layermask, and ignore the objects or areas that you don’t want. In your case, move the desire target object to a custom layer and only raycast to that layer.After that you will be able to accurately process your touch events.

Found this video quite useful:

source code is here:

http://www.revelopment.co.uk/tutorials/unitytutorials/73-howtorotateanobjectbytouch

Hope it helps.