Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Problem with character jump

Discussion in 'Physics' started by chrisswingsx, Dec 6, 2018 at 11:18 PM.

  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:
    66
    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:
    681
    Code or gtfo, we can't help without it.
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    849
    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.