Hello,
I’m developing a vertical scrolling shooter for Android on Unity 3.x.
I’m facing an issue with the touch movement speed of my main character, the touch speed is different on the different devices i try it on.
Here is my working code for the touch movementes (it WORKS, but at DIFFERENT SPEED on DIFFERENT DEVICES):
void Update () {
//**********************************************************************************
//||||||||||||||||||||||||||||| MOVEMENT |||||||||||||||||||||||||||||||||||||||||||
//**********************************************************************************
if (Input.touchCount > 0) // TOUCHSCREEN CONTROLS
{
// Get movement of the finger since last frame
touchDeltaPosition = Input.GetTouch(0).deltaPosition;
touchDeltaPosition.x *= touchSpeed;
touchDeltaPosition.y *= touchSpeed;
// Move object according to new positions
transform.Translate(touchDeltaPosition);
pos = transform.position;
transform.position = pos;
}
//**********************************************************************************
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//**********************************************************************************
}
You can check it better at void Update () { //*********************************************************** - Pastebin.com .
I’m convinced i have to use the Time.deltaTime somewhere here but i tried several options like:
transform.Translate(touchDeltaPosition * Time.deltaTime);
or
transform.position = pos * Time.deltaTime;
or (already looking for ANY kind of solution)
transform.Translate(touchDeltaPosition * Input.GetTouch(0).deltaTime);
or
transform.position = pos * touchDeltaTime;
And none of them worked for me.
Any ideas are appreciated,
Thanks!
found any solution?
– AkooleGame