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

Android Consistency

Discussion in 'Android' started by renman3000, Jun 7, 2014.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Hi there,
    I had built an app for iOS. All things worked perfectly.

    I built for Android and two things, one, my player speed was much lower despite being the same value as iOS, and of course audio delays (well documented).

    The audio issue is device related. Some devices experience a delay in firing an audio file.

    What I am wondering is, if on my device there is an audio delay and a speed of player drop... If I compensate my speed by inflating the value so it works fine on my device, is there the possibility that this value will over compensate on other devices?
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    How are you determining your speed?
     
  3. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Translate.

    I translate up at 600 speed, on tap. I degrade the speed at 45 per frame. This was the golden balance in iOS and desktop. However I need 800, 50 for a similar effect on android.
     
  4. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Are you multiplying your values by Time.deltaTime?

    Without that your speed is dependant on frames rather than time, so it should act differently on every device (except those with good enough performance to reach the framerate cap)
     
  5. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Yes, speed x time.deltaTime

    I take it you have never heard of this before? Perhaps it is something on my end, but it doubht it. Troubling thing is, all other bits in the game, move at speed.
     
  6. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Any chance you can post your troubling movement code?
     
  7. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    I don't have it in front of me...

    But it is like this....


    Code (csharp):
    1.  
    2. void btnPressed(){
    3. jumpSpeed = 600;
    4. }
    5.  
    6. void Update(){
    7. transform.Translate(Vector3.up * jumpSpeed * Time.deltaTime);
    8. jumpSpeed -= 45;
    9. if (jumpSpeed <= -600)
    10. jumpSpeed = -600;
    11. }
    12.  
    On my android, I was forced to inflate these values.
     
  8. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Code (csharp):
    1.  
    2. jumpSpeed -= 45;
    3.  
    4. // Should be:
    5.  
    6. jumpSpeed -= 45*Time.deltaTime;
    7.  
     
  9. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    That makes no difference. (Factoring Time.deltaTime into the equation) jumpSpeed is its own value, indifferent to tTime.deltaTime... But thanks!
     
  10. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    It does make a difference, it loses value over time.

    As it is now, it will change from 600 to -600 in 23 frames no matter how long it takes for those frames to render.

    If the game is progressing at 10 FPS it will take 2.3 seconds.
    If the game is progressing at 60 FPS it will take 0.38 seconds.
     
  11. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    Hm.
    Interesting.
    Will give it a shot.
    Cheers!
     
  12. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680