- Home /
GUITexture is lagging my object
Hi, I'm making an mobile breakout game and I got a problem when created the controls.
I made 2 GUITextures to move the paddle (left and right). But the way I made it's lagging a bit the paddle. It's not a smooth movement like when I was using OnGUI buttons. Also when I press both textures, at the same time, the paddle starts to move randomly to the sides.
This is my code:
void Update () {
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Stationary && ControlLeft.HitTest (touch.position)) {
transform.position += new Vector3(-moveSpeed, 0, 0)*Time.deltaTime;
}
else if (touch.phase == TouchPhase.Stationary && ControlRight.HitTest (touch.position)) {
transform.position += new Vector3(moveSpeed, 0, 0)*Time.deltaTime;
}
}
}
It probably must be result of my bad coding. What should I do to make the movement smooth?
This is a shot in the dark, but does the situation improve if you move this code to LateUpdate()?
No, still the same thing. I'll try to rewrite this code.
Edit: Solved it. I removed all the touch.phase condition. By the stationary method I could't move my finger neither a little bit or touch with other part of my finger. As TouchPhase.Stationary detect a finger touching the screen but hasn't moved.
Your answer
Follow this Question
Related Questions
null texture passed to GUI.DrawTexture 0 Answers
Animated Texture Offset 1 Answer
Touch gui texture buggy 0 Answers
Gui Texture Swap? 1 Answer
Hide/Unhide GUITexture Help! 1 Answer