Unity Touch Input Lagging In Mobile

Guys I am having a problem that when I install apk file in my mobile and play my game for test first 5mins its work fine but after then touch response getting slow then very slow too much late response why? how to fixed it?

 if (Input.touchCount > 0)
            {
                Touch touch = Input.GetTouch(0);
                switch (touch.phase)
                {
                    case TouchPhase.Began:
                        if (touch.position.x < Screen.width / 2 && touch.position.y <= Screen.height * (3 / 4f))
                        {
                            Basket_Ball.AddForce(new Vector2(-Move_Speed, 0f), ForceMode2D.Force);
                            Basket_Ball.velocity = Vector2.up * TapForce;
                        }
                        if (touch.position.x > Screen.width / 2 && touch.position.y <= Screen.height * (3 / 4f))
                        {
                            Basket_Ball.AddForce(new Vector2(Move_Speed, 0f), ForceMode2D.Force);
                            Basket_Ball.velocity = Vector2.up * TapForce;
                        }
                        break;
                    case TouchPhase.Ended:
                        //
                        break;
                }
            }

I am using this code for tap controls can any one help me to fix this issue?

How did you determine that that’s the part of your code that’s causing the problem?
If the game gets slow, then inputs will feel slow too. Doesnt have to be the inputs themselves that are getting slow. From the code you posted i cant see anything that would explain why the inputs are good first and then get slower.

i can’t try to reach the truth problem why touch getting so much lagged </3 :frowning: my game is almost ready to publish Help please

I can understand the stress, but unless i’m missing something the code posted above is not the problem. The only thing i see wrong with it is that you are handling inputs and physics in the same function, but that shouldnt be causing the problems you experience.
Fixing something that is not broken is just wasting time and not getting you closer to a solution.

Do you have these performance problems when running the app on PC in Unity? I’m assuming not, but probably just since PCs are more powerful, or maybe you just did not test for more than a couple minutes there. Thus i suggest running the game in Unity, checking how much performance it eats up (frame times in the profiler, and what takes up this time), then playing it 10 minutes (since you said the problem occurs after 5+ minutes) and then checking again.

I assume something causes a problem after longer time. One example of this would be a memory leak. More realistically you are probably adding (just as an example) elements to some list and never clear it, resulting in a longer list length over time, thus more time taken up by iterating the whole list, thus longer frametimes and thus “laggy gameplay”. Or maybe something like garbace collection causes spiked after a while. The easiest way to find these problems is by profiling your game, for example as described above.