Hello,
I’m new to Unity programming (I’ve already make an app’ on Xcode). I did a 2D game tutorial for unity, based on keyboard control, which allow me to understand the basics of the soft, but now, I began a new project, and I’m stuck for several hours on a problem : I do not manage to drag’n drop any object. I tried several parts of code I found on Internet, but none of them are working.
The fact is that I’m trying to run a very simple sample of code, but I just can’t understand why it’s not working :
function Update () {
//Debug.Log("Updating snowball");
for(touch in iPhoneInput.touches) {
Debug.Log("for loop");
if(touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began) {
transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 10));
}
}
}
I can see the Updating Snowball message, but I never enter the for loop, because my log never displays “for loop”, and so, my object is never moving. I’m finding this pretty wierd, because that means that IphoneInput.touches is empty…
I tried to attach this code to different objects (sphere, emptyGameObject, …), but it’s never working.
I really have no idea of where my problem comes from, and I’m really stuck.
Do I have to test this with a Iphone, or do Unity simulate the touches with a mouseClick ?
If anyone could help, I’d be thankfull !