Quantcast
Channel: Questions in topic: "unity remote"
Viewing all articles
Browse latest Browse all 297

Panning (translating) code works in Unity Remote 5, but not when installed on device

$
0
0
Hi, I'm using Unity 5.4.0f3 Personal on a Windows 10 machine, building for Android. I have a script that handles pinch zoom gesture as well as panning, all tied to a 2D game object (with children). The panning is in fact just moving the game object in 2D, inside a scroll window and it is meant to just follow the midpoint of the two finger touches. The scaling and the translation work just fine when testing them on my Android device using Unity Remote 5, but when the app is built and copied to the device and run, only the scaling works. The translation seems to manifest as extremely small changes (close to nothing) in position when in fact the fingers are dragged from one end to the other of the screen. Does anyone have an idea what could cause this difference in behaviour and how I could get past this problem? I've tried this on an Android 4.0.4 and on an Android 6.0 and faced the same problem. Thanks. Here is the code in question: if (Input.touchCount == 2) { // Store both touches. Touch touchZero = Input.GetTouch (0); Touch touchOne = Input.GetTouch (1); if (touchOne.phase == TouchPhase.Began) { //... } else if (touchOne.phase == TouchPhase.Moved) { // ... // Pan the image conform to the changes in the position of the midpoint. Vector2 pan = (touchZero.deltaPosition + touchOne.deltaPosition) / 2; transform.Translate (new Vector3 (pan.x, pan.y, 0), Space.World); //... } else { //... } }

Viewing all articles
Browse latest Browse all 297

Trending Articles



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