How can I make touch input work on my IPhone?
All I want is when I tap anywhere on my IPhone screen, to set didjump = true; I have looked at and tried so many tutorials about touch input but none of them worked. I just need a little help out with this and I have been trying for months so please don't link a tutorial, I have probably already seen it. Please respond with c# code. Thanks for your time.
Answer by Alamarche · Oct 17, 2015 at 07:03 PM
if (Input.touchCount > 0){
if (Input.GetTouch(0).phase == TouchPhase.Began){
didJump = true;
Debug.Log("Jumped"); //Just checks if all when well.
}
}
This code means that if you are touching the screen with more than 0 fingers and your touch just began, then set didJump to true.
Make sure that this code is in the Update() function.
Thanks for responding to me! But, when I run the app in xcode and through my Iphone it is not working. When the game is done being built in unity the console says "Game scripts or other custom code contains On$$anonymous$$ouse_event handlers. Presence of such handlers might impact performance on mobile devices" and "Failed to add the asset file size for sharedassets.1.resource "