Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Problem with character jump

Discussion in 'Physics' started by chrisswingsx, Dec 6, 2018.

  1. chrisswingsx

    chrisswingsx

    Joined:
    Oct 28, 2018
    Posts:
    5
    I have a 2D Runner for mobile and I put a coroutine so that every 5 seconds it increases its speed in 0.2 starts with a speed of 5 after 5 seconds it gets in 5.2 then 5.4 but the problem is that the more the speed increases the jump in x is bigger in travel and I would like the jump in x to be the same one with which it starts. Help me please. sorry my english is not so good
     
  2. xred13

    xred13

    Joined:
    Jul 14, 2018
    Posts:
    74
    What do you mean with jump in X increases? Could you post a video or something showing what happens?
     
  3. chrisswingsx

    chrisswingsx

    Joined:
    Oct 28, 2018
    Posts:
    5
    Coordinate Horizontal= X Vertical=Y
     
  4. SparrowsNest

    SparrowsNest

    Joined:
    Apr 6, 2017
    Posts:
    1,166
    Code or gtfo, we can't help without it.
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,164
    It sounds like conceptually your approach is a little flawed. Obvious this is just guesswork, but I'm assuming that your jump distance is based on how fast the player is moving, and that he stays in the air for a fixed amount of time. The faster you make the player move, the further he can jump, because you're moving him along through the world faster and faster.

    The only thing I can think of is that instead of adjusting the player's speed, you instead adjust Time.timeScale to make the game move faster. That will cause everything to go more quickly, without changing the physics. Your player will still jump the same distance, he'll just do it in a shorter amount of time. This might look bad though, as the whole world will speed up, not just the player.

    Otherwise I think you'd need to find some other approach to managing your player's air time, which probably won't play nicely with the physics simulation.

    Another approach is to embrace the player's added jump distance, and design your levels such that he needs to jump further. For example, start with shorter jumps, and then over time the jumps get further and more precise as the player's jump distance increases.