- Home /
How to fix this problem? ios touch screen?
My code for a ray that picks up an object when the screen is touched works well, but there is one problem, the screen is generally always being touched. Is there a way, so that it doesn't count the fingers already touching the screen? Thanks a ton,
My script:
 #pragma strict
 
 function Start () {
 
 }
 var guiray : GUIText;
 var flashlight : GameObject;
 var flashlightdesk : GameObject;
 function Update () {
       var hit : RaycastHit;
 var ray = camera.ScreenPointToRay (Vector3(200,200,0));
      Debug.DrawRay (ray.origin, ray.direction * 10, Color.yellow);
        var fwd = transform.TransformDirection (Vector3.forward);
 if (Physics.Raycast(ray, hit, 100)){
      //   print ("There is something in front of the object!");
   //  var fingerCount = 0;
  //   for (var touch : Touch in Input.touches) {
  //       if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
    //         fingerCount++;
  //   }
   //      if (fingerCount > 0){
   //      print ("User has " + fingerCount + " finger(s) touching the screen");
  if(hit.collider.gameObject.CompareTag("light")) {
 guiray.text = "Pick Up Flashlight"; 
     if (Input.touchCount > 0) {
    //place pick up code here!
    flashlight.gameObject.active = true;
       //flashlight.gameObject.enabled = true;
    flashlightdesk.gameObject.active = false;
 }
 }
 else {
 guiray.text = "";
 }
 }
 }
Answer by RyanZimmerman87 · Feb 18, 2013 at 12:48 AM
I am actually curious to if there is a preferred way for single touch commands for phones. As of now I am still just using what I used for my last PC project:
if (Input.GetButtonDown ("Fire1"))
As of now I haven't seen any reason to actually use the touch method. Maybe I am missing something?
I'm already touching the screen to move the camera, hence, it will always be "firing"
Edit: I lied, it works, thanks a quadrillion!
Your answer
 
 
             Follow this Question
Related Questions
Detect a tap versus standing touch on iPhone? 3 Answers
Touch input reporting 0 delta for first several Updates on iOS, 2 Answers
Way to detect and get last/latest TOUCH 5 Answers
Touch joystick tutorials ? 0 Answers
Best way to get to get touch inputs? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                