change unitys Input.mousePosition on mobile behaviour

i woul like the Input.mousePosition to be average of max two touches and that only if the distance of the two touches is below some value.
can this be done?

You should use Input.touches/GetTouch on mobile.

–Eric

1 Like

ok, thanks. but could you explain why not to use Input.mousePosition on mobile assuming its’s functionality is sufficient or close to sufficien like in my case. are there performance drawbacks or any known incopatibilities?

The mousePosition is not really suitable on mobile devices as it relies on a mouse (what a suprise! ;)). Thus any values you get from those are already interpolated values, e.g. as far as I can see the mousePosition already is the middle of the distance of the two touches if you have two fingers on the display. Not really something you can work with.

Using Input.touches gives you exact values of each touch’s position, making it easy to a) check for the distance between those two and b) perform action based on that distance.

If you’re doing calculations for two touches there’s no way you can use Input.mousePosition for that. Even with one touch, there is more to touch input than just position, such as TouchPhase, deltaPosition, etc., which is not available with Input.mousePosition.

–Eric

on my ipad Input.mousePosition is working with two touches exactly as i need it. it averages the positions. i dont need the delta and the touchphase. and since i’m prototyping i would like save time not having to reproduce its behaviour with GetTouch.

so my question is still the same: can i somehow override/extend the Input.mousePosition behaviour?

by the way: being new to unity3d and in this forum i would like to say that this is the most helpful forum i ever saw. thank you.

Being directly “straight in the face” here: The time spent on the discussion here would already have been sufficient to write that script. :wink:

But to answer that question: No, there is no way to extend that (in a way that will save you time compared to using Input.touches).