Calculate speed for different devices
Hello, my example is for android mobile devices.
I am following the unity documentation to move a gameObject the same distance and direction as registered by the movement of a finger.
The example works by adjusting the speed manually, however when testing on another android device I need more speed to travel the same distance.
How can I calculate which speed is the ideal for any device?
Thank you very much.
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public float speed = 0.1F;
void Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
// Get movement of the finger since last frame
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
// Move object across XY plane
transform.Translate(touchDeltaPosition.x * speed, touchDeltaPosition.y * speed, 0);
}
}
}
Your answer
Follow this Question
Related Questions
How to chanege the positionon of the cube when touching the screen? 0 Answers
Animation Progress Bar and Animation Always Has To Finish 1 Answer
Unusual Unit Slowdown 0 Answers
How to make my powerup last for about five seconds then go back to normal? 3 Answers
Space.Self smooth rotating menu around hand. How can I control the speed of the rotation?!?!? 0 Answers