Why does touch work in Remote, but not in build?

So I’m building a game for iOS, and I’ve made it so when I touch the iPad, an animation plays, where the player goes down an elevator. This works when I’m playing it in Unity Remote on my Mac perfectly, but not when I build the game and play it on the device. I’ve tried it on other iOS devices, still doesn’t work. There doen’t appear to be any errors either, I’ve tried messing with the script, but that doesn’t seem to do much either. I’ve litterally treid everything, and I can’t figure it out. It runs pretty smoothly too, so I don’t think its speed. It works fine, it just wont register my touches. So any help at all would be greatly appreciated, thanks.

P.S. In Xcode, it never runs automatically after I build it, I have to stop it and then click the application manually, otherwise it says “Paused” and stays at the Unity Logo

Here is a screenshot: http://i.imgur.com/4KDaUAQ.png

Here are the two variations of the script, one where you just have to touch the screen, and the other where you have to hit the glass.

  var menuMusic:GameObject;
    var elevatorsounds:GameObject;
    var elevator:GameObject;
    var glasssdingsoundeffect:GameObject;
    var rain1:GameObject;
    var rain2:GameObject;
    var deletetext:GameObject;
    var deletetext1:GameObject;
      function FixedUpdate () {
     DontDestroyOnLoad (rain1.gameObject);
         if (Input.GetMouseButtonDown(0)){
                    // Makes the camera follow this object by
        // making it a child of this transform.
        // Get the transform of the camera
        var cameraTransform = Camera.main.transform;     
        // make it a child of the current object
        cameraTransform.parent = elevator.transform; 
      cameraTransform.transform.rotation = Quaternion.identity;
      glasssdingsoundeffect.audio.Play();
       Destroy (deletetext1);
      Invoke("elevatormove1", 1.3);
        Invoke("detach", 11.3);
                }
            }
    
    function FadeOutSound(){
        if (!rain1){
          // Get menuMusic if not already defined in Inspector
          //rain1 = GameObject.Find("MenuMusic");
        }
        if (rain1) {
            // wait 4 seconds then fades for 4.5s
            yield WaitForSeconds (10);
            for (var i = 9; i > 0; i--){
              rain1.audio.volume = i * .1;
              yield new WaitForSeconds (.2);
              print ("Fading...");
            }
            rain1.audio.volume = 0;
        }
    }
    
    function elevatormove1 () {
    //elevator.audio.Play();
    elevator.animation.Play("1");
      elevator.audio.Play();
    FadeOutSound();
     Destroy (deletetext);
    
    }
    
    function detach () {
    transform.parent = null;
     animation.Play("move1");
      Destroy (rain2);
      menuMusic.audio.Play();
    }

and

   private var hit : RaycastHit;
    private var ray : Ray;//ray we create when we touch the screen
    var menuMusic : GameObject;
    var elevatorsounds : GameObject;
    var elevator : GameObject;
    var glasssdingsoundeffect : GameObject;
    var rain1 : GameObject;
    var rain2 : GameObject;
    var deletetext : GameObject;
    var deletetext1 : GameObject;
      function FixedUpdate () {
     DontDestroyOnLoad (rain1.gameObject);
        if(iPhoneInput.touchCount == 1) {
            ray = Camera.main.ScreenPointToRay(iPhoneInput.touches[0].position);
            Debug.DrawLine(ray.origin,ray.direction * 10);
            if(Physics.Raycast(ray.origin, ray.direction * 10,hit)){
                Debug.Log(hit.transform.name);//Object you touched
                
                		            			if(hit.transform.name == "Elevator Glass"){
                    // Makes the camera follow this object by
        // making it a child of this transform.
        // Get the transform of the camera
        var cameraTransform = Camera.main.transform;     
        // make it a child of the current object
        cameraTransform.parent = elevator.transform; 
      cameraTransform.transform.rotation = Quaternion.identity;
      glasssdingsoundeffect.audio.Play();
       Destroy (deletetext1);
      Invoke("elevatormove1", 1.3);
        Invoke("detach", 11.3);
                }
            }
        }
    } 
    
    
    function elevatormove1 () {
    //elevator.audio.Play();
    elevator.animation.Play("1");
      elevator.audio.Play();
     Destroy (deletetext);
    
    }
    
    function detach () {
    transform.parent = null;
     animation.Play("move1");
      Destroy (rain2);
      menuMusic.audio.Play();
    }

Sorry, I really need help with this, anyone?

One thing I see is that you’re using FixedUpdate, which really should not be used for input since it doesn’t run at the same rate that the screen updates and can miss events. The formatting makes it quite difficult to follow what’s going on, but I can also see that you’re repeatedly calling DontDestroyOnLoad, which should only be called once.

–Eric

Thank you so much, what took you a minute, I couldn’t even figure out with 6 hours of work.

I owe you a ton,
thanks again

I thought I had ruined my first impressive game

I just overcome the same problem.
The problem was, that I had 2 spots in my code that I did input check. One was in the Update() where I was checking for TouchInputs and I was calling a foo() methods if I detected a touch, and also I had a onMouseDown() methode (because I was developing in a computer ofcource and I wanted to test the game with mouse clicks) that called the same foo() methode. Propably (it is very comon) in a game, a touch does a selection. You tap something to select it, and propably you hav coded already that if you select it again it deselects. So if you have both methodes (touch and mouse) because unity on a mobile translates touches to mouse events, you’ll call foo() twice. So your object will be selected and deselected on an instance and you would think that touch didn’t work. But it did. :wink: So check if you have a leftOver OnMouseDown methode somewhere and comment it out before you build. I hope taht helped…