Touch radius always returns zero on Android
I am trying to use Touch.radius (as well as radiusVariance) on my Galaxy S7 and I only get zero:
https://docs.unity3d.com/ScriptReference/Touch-radius.html
I get numbers with the Touch Radius Test app:
https://play.google.com/store/apps/details?id=com.bzgames.touchgraph
Am I missing a build setting or is it a device compatibility issue?
The code is below and it reports positions X and Y just fine.
using UnityEngine;
using System.Collections;
public class TouchTest : MonoBehaviour {
Touch currentTouch;
int count = 0;
float radius = 0;
float variance = 0;
float min = 0;
float max = 0;
float pressure = 0;
float x = 0;
float y = 0;
// Use this for initialization
void Start () {
Screen.orientation = ScreenOrientation.Portrait;
}
// Update is called once per frame
void Update () {
if (Input.touchCount > 0) {
count = Input.touchCount;
currentTouch = Input.GetTouch (0);
radius = currentTouch.radius;
variance = currentTouch.radiusVariance;
min = radius - variance;
max = radius + variance;
pressure = currentTouch.pressure;
x = currentTouch.position.x;
y = currentTouch.position.y;
} else {
count = 0;
}
}
void OnGUI () {
GUI.Label (new Rect(0,0,100,100), "Radius: " + radius);
GUI.Label (new Rect(0,50,100,100), "Variance: " + variance);
GUI.Label (new Rect(0,100,100,100), "Min: " + min);
GUI.Label (new Rect(0,150,100,100), "Max: " + max);
GUI.Label (new Rect(0,200,100,100), "Pressure: " + pressure);
GUI.Label (new Rect(0,250,100,100), "Touches: " + count);
GUI.Label (new Rect(0,300,100,100), "X: " + x);
GUI.Label (new Rect(0,350,100,100), "Y: " + y);
}
}
EDIT: I just confirmed it's the same case with my Galaxy Tab S tablet :/
can we see the code? maybe you're not Reding a fresh touch Information every frame, but the touch from the first.
yeah, that's bogus. I think that's a bug alright. you should report it.
Your answer
Follow this Question
Related Questions
Please Help Im confuse im beginner in using unity. 1 Answer
Player follow touch when holding down your finger on the screen (C#) 1 Answer
How to pick up an object when touching a button(Mobile) 0 Answers
Non-responsive touch controls after showing ads. 0 Answers
Massive lag spike on first Input.GetTouch with nothing on scene but one script (Android) 2 Answers