- Home /
Android Touch Lag but not on iOS
EDIT I just wanted to bump this in hopes that someone possibly knows what is wrong. I think its a setting in the editor since the same exact script works totally fine on iOS, but after trying to mess with target framerate and vsync nothing has changed.
Hello,
I released a game on iOS (everything worked perfectly) and have now released it on Android but I am getting complaints that my player character has laggy input. I can't figure out why this is happening, especially since it worked totally fine on iOS. I found the script below and have been using it for both platforms for my characters controls:
using UnityEngine;
using System.Collections;
public class MoveControls : MonoBehaviour {
public GameObject player;
// Update is called once per frame
void Update ()
{
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Stationary)
{
Vector2 touchPosition = Input.GetTouch(0).position;
double halfScreen = Screen.width / 2.0;
if(touchPosition.x < halfScreen)
{
player.transform.Translate(Vector3.left * 6 * Time.deltaTime);
}
else if(touchPosition.x > halfScreen)
{
player.transform.Translate(Vector3.right * 6 * Time.deltaTime);
}
}
}
}
I did port this from iOS to Android so I don't know if some type of settings may be a problem? And I don't have any errors either. If anyone can point me in the right direction I would be very grateful.
Thanks!
Is your player colliding somewhere cuz transform.Translate is not for collisions(bad for physics) and that may cause lag,by the way what is name of your game,i would like to try it :)
The name is "dodge drop pop" but I have another idea, my vsync is set to "every second Vblank" and I have a script that sets Application.targetframerate to 30 fps, could that be the problem?
And my player isn't colliding with anything, he is floating, there is no floor/grounded type of thing.
hmmmmm,have you tried transform.Translate(0,0,0); this:
using UnityEngine;
using System.Collections;
public class $$anonymous$$oveControls : $$anonymous$$onoBehaviour {
public GameObject player;
// Update is called once per frame
void Update ()
{
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Stationary)
{
Vector2 touchPosition = Input.GetTouch(0).position;
double halfScreen = Screen.width / 2.0;
if(touchPosition.x < halfScreen)
{
player.transform.Translate(-6*Time.deltaTime,0,0);
}
else if(touchPosition.x > halfScreen)
{
player.transform.Translate(6*Time.deltaTime,0,0);
}
}
}
}
I have not but isn't that the same thing I'm doing, but just a different way of writing it?
Have you changed anything since last update? Everything works perfectly now.