Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Different Touch iOS work fine/Android problem

$
0
0
Hi All, I have a code for move a cube around my screen, I have this code public float speed; public float Maxspeed; private Vector3 pos; private Vector2 previousPos; void Start() { previousPos = transform.position; } void FixedUpdate () { MoveCube(); previousPos = transform.position; } void MoveCube() { if(GameController.instance.StartGame) { Ray ray; RaycastHit hit; if(Input.touchCount == 1) { Touch touch = Input.GetTouch(0); ray = Camera.main.ScreenPointToRay(touch.position); if(Input.GetTouch(0).phase == TouchPhase.Moved) { if(Physics.Raycast(ray,out hit,100)) { pos = Input.GetTouch(0).deltaPosition * speed; //rigidbody.MovePosition(pos + transform.position); rigidbody.velocity = Vector3.ClampMagnitude(pos,Maxspeed); } }else if (Input.GetTouch(0).phase == TouchPhase.Stationary || Input.GetTouch(0).phase == TouchPhase.Canceled || Input.GetTouch(0).phase == TouchPhase.Ended) { rigidbody.velocity = Vector3.zero; } } }else { rigidbody.velocity = Vector3.zero; } } This code work fine on iOS, but on Android, the cube move slow and "jumping". Any help?

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>