Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Unity: strangeness of simple game while adopting to Android

Discussion in 'Android' started by mun001, Jun 16, 2023.

  1. mun001

    mun001

    Joined:
    Sep 29, 2019
    Posts:
    5
    Hello!

    I need some help, not sure what's happening.. The story is - simple game, Hero, moving & jumping, and firing to enemies. Started to adopt it to mobile, let' say just add buttons of moving & firing.

    The issue is -> just added a Button (Text Mesh Pro) with link to firing function. In testing (not connected to mobile device) all Ok (when i press Button, even while jumping, bullet object is instancied exact at moment when i press it). But going to test on device & even with compiled APK on mobile, a delay of pressing button and instance a bullet is exists, no way to normal gaming ;(((

    Samsung Galaxy S23 Ultra, as a device.. What can be wrong??

    Thanks in advance!!
     
    Last edited: Jun 16, 2023
    Unifikation likes this.
  2. mun001

    mun001

    Joined:
    Sep 29, 2019
    Posts:
    5
    Any ideas?.. I am afraid to go to more complex games with such issues :(
    Thanks!
     
  3. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    Lag on all touch screens is a problem, much bigger on Android than iOS.

    Best way to fix this, that I know of, for best results at all sorts of other compromises, is to use a much faster timing system to register and set input flags for touches, and then read those flags in the next Update to do any and all updates to your game world.

    The tacky way to do this is set fixedUpdate to 4x your target frame rate and ingest input in there, and set those flags, then read them and reset them in Update.
     
  4. mun001

    mun001

    Joined:
    Sep 29, 2019
    Posts:
    5
    ok, but Button event directly linked to function that do an instantiation.. But anyway, will try with flags approach, thanks a lot for direction!
     
    Unifikation likes this.
  5. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    Yes, I know. You'd expect that a button and a function call coming from it would be optimised, that a game engine would have done its utmost to do the best for its most appropriate audiences and uses... but it's not, and they haven't.
     
  6. mun001

    mun001

    Joined:
    Sep 29, 2019
    Posts:
    5
    ;((( that's a really disappointing me.. how when people doing even simple games for Android using Unity if even in this case it is not working as logicaly expected.. And this lag is on top Android device, how it will be on "normal" middle-range devices, i am already afraid..
     
  7. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    Have a look at this post, discussing the same technique you're using:

    Jul 6, 2019

    Some say that the New Input System is faster. Using that you'll have to become a Unity savant. It's about as contrived as anything can be within the Unity Systems. And it doesn't solve the problems of UI, you'll have to seek its touches and then test for where and what they've touched. And this is jumble between two different spaces, at best, and then Z etc.

    Unity is in a state of flux, and it doesn't look like resolving all the systems and issues it's gotten over the last 5 years for at least another 5 years, as DOTS, the thing that's causing this fluctuation, has only just been "finished" so that they can now begin optimising and re-engineering all their systems around this new approach to performance. Things like a new audio system and animation system are still in the design consideration stage.

    If you have other engine choices, and you're new to Unity, I'd be taking a long hard look at the other options, especially for a good phone like that.
     
  8. mun001

    mun001

    Joined:
    Sep 29, 2019
    Posts:
    5
    Thanks) Appreciate.. Trying Godot 4 now..