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();
}
