Hi,
I’m new to Unity and am trying to use it to create a game for Android (or other platforms but focusing on Android to start) and I was wondering how I can add a touch listener for an object (just using simple cubes right now). In the Update() if I add some similar to seen below I can get things to happen on or around the object when the screen is touched but I only want this when it is on top of the object not just anytime.
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
rigidbody.AddExplosionForce(forceAmount, transform.position, 25.0f, 1.0f);
}
So my question is how can I have this happen only when the user actually touches in the cube and not anywhere on the screen. Is there a good way or do I just need to check the position of the cube vs the position of the touch? Thanks in advance,
Jason