Author Topic: Unexpected "Swipe" Performance on iOS  (Read 2611 times)

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Unexpected "Swipe" Performance on iOS
« on: March 15, 2013, 10:19:31 PM »
Is there anything wrong with the following method to detect an object and process a method on the object called Clicked()? Basically what I'm seeing is fast swipe gestures across iPhone are not recording multiple objects hit in a row and sometimes not even a single object if the swipe is fast enough.

If the finger is moved slowly all objects are processed without any issues at all.

UICamera on my ortho game camera with mouse and joystick disabled, tried sticky keys enabled/disabled. 

  1.        
  2.           void Update() {      
  3.                 //ensure game isnt paused before allowing clicking on the screen colliders
  4.                 if(!areaTimer.gamePaused) {
  5.                         //if game is running on ios or android, get hovered object by simply getting whatever is hovered
  6.                         if(isMobilePlatform) { 
  7.                                 GetHoveredObject();    
  8.                         }
  9.                         //else require mouse button down to return the hovered object as a hit detection
  10.                         else {
  11.                                 if(Input.GetMouseButton(0)) {
  12.                                         GetHoveredObject();    
  13.                                 }
  14.                         }
  15.                 }
  16.            }
  17.  
  18.         //ray casting calls this to detect hit objects
  19.         void GetHoveredObject() {
  20.                 //if there is no hovered object, do nothing
  21.                 if(UICamera.hoveredObject) {
  22.                
  23.                         hitObject = UICamera.hoveredObject.gameObject;
  24.                        
  25.                         //get the items clicked function depending on the tag and process the clicked method on the game object
  26.                         switch(hitObject.tag) {
  27.                                 case "Treasure":
  28.                                         hitObject.GetComponent<TreasureItem>().Clicked();
  29.                                         break;
  30.                                 case "Enemy":
  31.                                         hitObject.GetComponent<EnemyItem>().Clicked();
  32.                                         break;
  33.                                 case "EnemyProjectile":
  34.                                         //hitObject.GetComponent<EnemyProjectile>().Clicked();
  35.                                         break;                                         
  36.                                 default:
  37.                                         break;
  38.                         }
  39.                 }
  40.         }
  41.  
  42.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unexpected "Swipe" Performance on iOS
« Reply #1 on: March 16, 2013, 09:22:52 AM »
Performance related, likely. Raycasts are done in Update, and if there are not enough updates, you won't see what was hit.