简体   繁体   中英

How to speed up endless runner

I've already worked with Unity2D but for the first time created project in Unity3D. I'm making endless runner for my portfolio and have no idea how to calculate the optimal speed of the game. Is there a speed formula or something like that to always start the game easy but moves to more and more difficult never becoming impossible.

There are 2 generally accepted answers for speeding up a game:

  1. Build your game logic with a variable speed parameter and include it within your controller and game logic scripts. The benefit to this approach is that it allows you control exactly what you want to speed up and what you don't want to speed up. The downside is that you will need to modify all scripts to use a speedMultiplier:

     vector3 direction; float speed = 1.0f; Update() { direction = //Set direction using inputs } FixedUpdate() { rigidbody.velocity = direction * speed }
  2. Modify Time.timeScale. Time.timeScale is a built in multiplier for everything that relies on deltaTime. If you set Time.timeScale = 2.0f, your game will perform logic as if twice as much time has passed. This includes animations, physics, and any other time-based game logic). If you set Time.timeScale = 0.0f, your game will be paused. This is very useful if you just want to speed up everything.

     time.timeScale = multiplier;

    A common problem that people run into when using time.timeScale is their animations feel disjointed because of the warped time scale. You can specify the Update Mode of the animator to Unscaled Time to keep animations running at a constant speed regardless of the time scale to prevent this.

have a look on logarithmic functions.

type "y = 10log a" on this calculator to see the value range.

this will increase your speed faster when far from the limit then slower once it gets closer.

in the case "y = 10log a"

  • if a = 1, y = 0
  • if a = 10, y = 10
  • if a = 100, y = 20
  • and so on.

so it does not have an upper limit but you can impose it to stop at 100 or 1000, and it will easily add speed at first but the fastest it goes the slower it accelerates

in short the higher is "a" the slower "y" moves.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM