hello, I can do to android as it touches the screen and I leave an object

hi, i find this script in YouTube but is for iPhone and not work in android.

var targetItem : GameObject;

//Dragging limits

var horizontalLimit : float = 2.5;
var verticalLimit : float = 2.5;



private var scrollDistanceX : float;
private var scrollDistanceY : float;


private var hit: RaycastHit;
private var layerMask = (1 < 0) 
 { // If there are touches...
 var theTouch : Touch = Input.GetTouch (0); // Cache Touch (0)
 
 var ray = Camera.main.ScreenPointToRay(theTouch.position);
 
 
 
          if(Physics.Raycast(ray,hit,50,layerMask))
          { 
          
          if(Input.touchCount == 1)
 {
 
 
 
 var scrollDeltaX = theTouch.deltaPosition.x;
 var scrollDeltaY = theTouch.deltaPosition.y;
 
 
 scrollDistanceX = Mathf.Clamp(scrollDistanceX+scrollDeltaX*Time.deltaTime*.5,-horizontalLimit,horizontalLimit);
 scrollDistanceY = Mathf.Clamp(scrollDistanceY+scrollDeltaY*Time.deltaTime*.5,-verticalLimit,verticalLimit);
 
 
 
 targetItem.transform.position.x = scrollDistanceX;
 targetItem.transform.position.y = scrollDistanceY;
 

 }
          
 
 }


 
 
 
 }
 
}

HOW I PUT AN SCRIPT THAT MAKE THIS IN ANDROID?

PLEASE.

Please format your code properly using the 101010 button. Don't shout. In all likelihood this does work for Android but you are perhaps not using it properly. I suggest you ask at the place you found the script.

i find this in a desert web-page sorry for the letter

1 Answer

1

While there are several problems with this script, and you should ask whoever wrote it about that, this should work with iOS and Android same way. You just build it for Android.