Beginners scripting question for touching 3d object

what would the script function be if you have a scene with several
3d object and when you touch in the iphone/itouch in the 3d scene
on a 3object to play a sound. I know the function to play a sound
but how can you create the trigger when you touch the object?

you could go for a raycast, but you would need your objects to have a collider:

have a look at the last example, this is pretty much what you want.

if you don’t want your objects to have colliders, you could use Camera.ScreenToWorldPoint and search for the nearest object, this could be a little faster as it does not involve physics, but is more work.

  1. a put a cube in my scene

  2. add a sound to it and remove the play on awake

  3. add this script to it
    function Update () {
    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit : RaycastHit;
    if (Physics.Raycast (ray, hit, 100)) {
    //Debug.DrawLine (ray.origin, hit.point)
    audio.Play();
    }
    }

  4. does my box needs to be set ot Is Trigger?

i don’t get it to work

Did you confirm that the line gets drawn to the collision point? I had a problem with this before i added a collision box to my game object. You might not be getting a collision when you think you should and thus your audio will not play.