Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Different jump height at different pc`s?

Discussion in 'Scripting' started by Tiles, Sep 5, 2011.

  1. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    My character movement is basically based at the example form the script reference, which can be found here:

    http://unity3d.com/support/documentation/ScriptReference/CharacterController.Move.html

    After publishing a first prototype i have a user that is not able to jump high enough to reach the next platform. Something that works perfect at my pc and my laptop. A screenshot has showed me that the fps at his pc is very low. At around 15 fps when he made the shot. And he has indeed used a very weak laptop here, with an Intel graphics chip too.

    I`m a bit clueless what to do, since the code already uses Time.deltaTime. Isn`t Time.deltaTime meant to avoid such things? Is there anything i can do so that the jump height is really equal, no matter at which pc or with which framerate the game runs?
     
  2. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    Have it. Nothing to do with Time.deltaTime. I have to use function FixedUpdate instead function Update. Then the jump height is equal.

    As a sidenote, the example in the manual should use FixedUpdate too.
     
  3. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    How are you defining your jump code? That's probably the more important factor.
     
  4. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    Try this code in your Update function. That'll make your character jump up 2.0m every jump. Much more predictable than just giving an arbitrary upwards force.

    Code (csharp):
    1.  
    2. var jumpHeight : float = 2.0;
    3.  
    4. moveDirection.y = Mathf.Sqrt ( 2 * jumpHeight * gravity );
    5.  
     
  5. Tiles

    Tiles

    Joined:
    Feb 5, 2010
    Posts:
    2,481
    As told, it`s as in the Unity code example from the reference. By setting the movedirection.y directly to a value. And thanks for your code example :)