- Home /
Why my app bug when I test on mobile?
On desktop it works, but when I build on mobile it BUG so hard, the direcions don't work. That's the code.
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour { Vector3 posicaoMouseAtual; Vector3 posicaoMouseInicial; Vector3 direcao;
bool cuboMoveu;
public GameObject cubo;
// Use this for initialization
void Start()
{
// posicaoMouseAtual = Vector3.zero;
//posicaoMouseInicial = Vector3.zero;
cuboMoveu = false;
direcao = cubo.transform.position;
}
// Update is called once per frame
void Update()
{
MoveCubo(0.01f);
Debug.Log(posicaoMouseAtual);
}
void OnMouseDown()
{
posicaoMouseInicial = Input.mousePosition;
posicaoMouseAtual = Input.mousePosition;
cuboMoveu = false;
}
void OnMouseDrag()
{
posicaoMouseAtual = Input.mousePosition;
}
Vector3 ChecaDirecao(Vector3 posClick, Vector3 posAtual)
{
float qtdMoveMouse;
qtdMoveMouse = 70f;
if (!cuboMoveu)
{
if (posAtual.x > posClick.x + qtdMoveMouse)
{
direcao = Vector3.right;
cuboMoveu = true;
}
else if (posAtual.x < posClick.x - qtdMoveMouse)
{
direcao = -Vector3.right;
cuboMoveu = true;
}
else if (posAtual.y > posClick.y + qtdMoveMouse)
{
direcao = Vector3.up;
cuboMoveu = true;
}
else if (posAtual.y < posClick.y - qtdMoveMouse)
{
direcao = -Vector3.up;
cuboMoveu = true;
}
}
return direcao;
}
void MoveCubo(float velocidade)
{
velocidade += Time.deltaTime;
cubo.transform.Translate(ChecaDirecao(posicaoMouseInicial, posicaoMouseAtual) * velocidade);
}
}
Answer by pacific00 · Jul 02, 2014 at 04:23 AM
try removing the debug.log in update , sometimes it brings down the frame rate..
Answer by Vardan Meliksetyan · Jul 02, 2014 at 08:54 AM
Lets do this go File-> Build Settings-> check Development Build and you can test Autoconnect Profiler. After that if you have error it will show you. @pacific00 answer about Debug.Log() it is normal compiler will ignore it.
Your answer

Follow this Question
Related Questions
Main Menu: Is it better to subdivide it into different scenes? 1 Answer
How to save a text file in Windows 8 3 Answers
Cryptic Android Crash message, anyoen know what this means? 0 Answers
Android Swipe In 3D World 1 Answer
How do you access the "Auto Time" or "Network-Based Time" on Android? 1 Answer