简体   繁体   English

如何加速无尽的跑步者

[英]How to speed up endless runner

I've already worked with Unity2D but for the first time created project in Unity3D.我已经使用过 Unity2D,但这是第一次在 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:缺点是您需要修改所有脚本才能使用 speedMultiplier:

     vector3 direction; float speed = 1.0f; Update() { direction = //Set direction using inputs } FixedUpdate() { rigidbody.velocity = direction * speed }
  2. Modify Time.timeScale.修改 Time.timeScale。 Time.timeScale is a built in multiplier for everything that relies on deltaTime. Time.timeScale 是所有依赖于 deltaTime 的内置乘法器 If you set Time.timeScale = 2.0f, your game will perform logic as if twice as much time has passed.如果您设置 Time.timeScale = 2.0f,您的游戏将执行逻辑,就好像已经过去了两倍的时间。 This includes animations, physics, and any other time-based game logic).这包括动画、物理和任何其他基于时间的游戏逻辑)。 If you set Time.timeScale = 0.0f, your game will be paused.如果您设置 Time.timeScale = 0.0f,您的游戏将暂停。 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.人们在使用 time.timeScale 时遇到的一个常见问题是,由于时间尺度扭曲,他们的动画感觉不连贯。 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.您可以将动画师的更新模式指定为Unscaled Time以保持动画以恒定速度运行,无论时间尺度如何,以防止这种情况发生。

have a look on logarithmic functions.看看对函数。

type "y = 10log a" on this calculator to see the value range.在此计算器上键入“y = 10log a”以查看值范围。

this will increase your speed faster when far from the limit then slower once it gets closer.这将在远离极限时更快地提高你的速度,一旦接近极限就会变慢。

in the case "y = 10log a"在“y = 10log a”的情况下

  • if a = 1, y = 0如果 a = 1,则 y = 0
  • if a = 10, y = 10如果 a = 10,则 y = 10
  • if a = 100, y = 20如果 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所以它没有上限,但你可以强加它在 100 或 1000 处停止,它起初很容易增加速度,但速度越快加速越慢

in short the higher is "a" the slower "y" moves.简而言之,“a”越高,“y”移动越慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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