I’ve been working on a mobile project in Unity and I’m running into some serious issues with touch input delay on Android 11. It’s really frustrating because I want it to be smooth and responsive, but every button press feels laggy—like there’s a 200-300ms delay.
Here’s a bit of context: I’ve set up my buttons using `rectTransforms` in the `Start()` method and I’m reading touch inputs in the `Update()` loop with the code snippet below:
“`csharp
foreach (Touch touch in Touch.activeTouches)
{
Vector2 pos = touch.screenPosition;
if (player.leftRect.Contains(pos))
input = -1f;
if (player.rightRect.Contains(pos))
input = 1f;
if (player.jumpRect.Contains(pos))
{
jumpHeld = true;
if (touch.phase == TouchPhase.Began)
jumpPressed = true;
}
if (player.dashRect.Contains(pos) && touch.phase == TouchPhase.Began)
dashPressed = true;
}
“`
The button logic seems straightforward, but when I build the game and test it on my device, it feels like I’m pressing the buttons in slow motion. I’ve also tried switching to Unity’s new Input System, thinking it might help, but that only seemed to make things worse—now the latency is around 500ms!
I’m starting to think it might be something specific to my implementation or possibly how I’m handling the input data. Other games run super smoothly on this phone, so I can’t figure out why mine is lagging.
Are there any best practices or optimizations that I might be missing? Maybe something I should change in how I handle touch inputs or something related to performance settings for mobile? Any tips or advice from your experiences would really be appreciated!
The input delay you’re experiencing is likely related to how you’re processing touch inputs directly within the
Update()
method. Touch inputs on Android can often benefit significantly from being handled in theFixedUpdate()
or utilizing Unity’s EventSystem with dedicated UI components (such asButton
andEventTrigger
) rather than manually checking touch positions each frame. Consider using Unity’s built-in UI system with Event triggers, or implementing the IPointer interfaces likeIPointerDownHandler
, which can detect user interactions reliably and immediately without delay. Additionally, ensure your rendering and physics settings are optimized—reduce draw calls, disable unnecessary graphics or post-processing effects, verify your project’s performance settings (such as target frame rate and Quality settings), and ensure the Android-specific settings are correctly configured for input responsiveness.If you’ve already attempted Unity’s new Input System and experienced even worse latency, you might be hitting compatibility or configuration issues there. If you’re continuing to directly poll touches, make absolutely sure you aren’t inadvertently delaying input processing by operations like heavy calculations or allocations happening within the input loop. Profile your app using Unity’s Profiler to reveal if CPU spikes or garbage collection are involved. Consider using native Android input methods or plugins designed specifically for touch responsiveness. Ultimately, tightly controlling the input cycle and leveraging either native Unity UI events or dedicated input phases (like tracking
TouchPhase.Began
) efficiently is your best path forward for low-latency, responsive touch handling.Touch Input Delay in Unity for Android
Sounds like you are really facing some nasty input lag! Here are a few tips you might want to try out:
1. Update Method Tuning
First off, ensure that your touch input handling is efficient. You could try limiting the number of checks for touch inputs. Instead of checking for “Contains” for each touch, you could create a helper method that checks both
RectTransform
and their current touch positions, only looping through relevant touches. This could reduce some of the overhead.2. Fixed Update vs. Update
You might want to consider using
FixedUpdate()
instead ofUpdate()
for handling inputs, especially if physics are involved. Even though FixedUpdate is generally for physics, sometimes it can actually help in reducing jitter, depending on how your project is structured.3. Input System Settings
Since you mentioned using Unity’s new Input System, make sure you’ve properly set your touch settings in the input actions. Sometimes, tweaking the settings can reduce any latency. What about trying out different update modes? You could go with
Process Events
for your controls.4. Avoid Overdraw
Another thing to watch for is overdraw in your UI. If your UI has many overlapping elements or is part of a complex canvas hierarchy, it could impact performance, leading to delays. Try to limit the draw calls by adjusting your UI hierarchy or batching your UI.
5. Performance Settings
In Unity, check some graphics settings related to quality levels. Sometimes, setting these too high can lead to performance hits on mobile devices. A good practice is to test with lower quality settings to see if that helps.
6. Use TouchPhase Correctly
Make sure you’re using
TouchPhase.Stationary
effectively as well. Sometimes capturing when a touch is still on the screen helps in making continuous actions more responsive without feeling delay on initial touches.Hope these tips help you get that smooth touch response you’re aiming for! It can be really tricky working with mobile input, so just keep experimenting.