Search Unity

A speed problem

Discussion in 'Scripting' started by Train, Jun 3, 2011.

  1. Train

    Train

    Joined:
    Apr 22, 2008
    Posts:
    344
    Hi!

    At the moment i create a new web game and i have a speed problem with the different browser systems.
    When i take the Mozilla Firefox, than i have the same speed like the engine version. When i take the Safari Browser, the speed is faster as both versions. I work with Time.deltaTime and at the moment i don`t no, what can i do to, to clear the problem. I hope anyone can help.

    Here the little code from a GUI movement:

    Code (csharp):
    1. var xmove : float = 2;
    2. var speedtime : float = 0.6;
    3.  
    4.  function Update () {
    5.       xmove += 1;
    6.       speedtime -= 0.003;
    7.    
    8.      if  (xmove < 300){
    9.       transform.position -= Vector3.up * Time.deltaTime *  speedtime ;
    10. }
    11. if (xmove >= 300){
    12.   xmove = 300;
    13.   speedtime = 0;
    14.    }
    15.  }
    16.  
    Regards, Train
     
  2. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    change Time.deltaTime to Time.smoothDeltaTime, that may fix your problem
     
  3. Train

    Train

    Joined:
    Apr 22, 2008
    Posts:
    344
    No BigMisterB, i have the same problem with Time.smoothDeltaTime. Hmm... :(
     
  4. Falin

    Falin

    Joined:
    Sep 29, 2009
    Posts:
    242
    You can put Debug.Log(Time.deltaTime) somewhere in your script and then look wich the average number is when it plays in the editor.
    Change Time.deltaTime with that number. maybe that will work
    I don't know if this is good scripting but you can always try
     
  5. Train

    Train

    Joined:
    Apr 22, 2008
    Posts:
    344
    ok i try this, hope it works
     
  6. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    The issue is that you're moving the transform.position using Time.deltaTime, but xmove and speedtime aren't being changed using Time.deltaTIme. As a result, the faster the browser or the higher the number of frames, the faster those values will adjust.

    Try adjusting the values so you can multiply them with Time.deltaTime.

    xmove += Time.deltaTime;
    speedTime -= 0.003 * Time.deltaTime;
     
    Last edited: Jun 4, 2011
  7. Train

    Train

    Joined:
    Apr 22, 2008
    Posts:
    344
    Thanks for the tip, i change it and now it works. But into the firefox browser it jerks, but the x and y is now the same. Is it possible that apple works better with Safari as with Firefox ? I think this is the problem now.