How do I Programmatically Calculate Spawn Seconds Based on Speed

0 favourites
  • 5 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Say I have the following:

    20 (speed) = 10 (spawn time in seconds)

    100 = 3

    200 = 2,25

    How do I programme a formula for the seconds so that the values of seconds get automatically calculated based on the user's speed input according to the pattern above?

    Say the user wants now a speed of 250. How do I programme the formula calculation for the seconds based on the above pattern? Of course the calculation should work for any given input of speed, like 10 for instance. I am really lost here.

  • It's hard to find the exact formula, because your numbers are pretty much random, this is the closest I could make:

    spawn_rate = (200+speed)/speed

    You can add clamp((200+speed)/speed, 0.5, 15) to set minimum and maximum spawn rates.

  • Yeah, they are kind of random, all I wanted to do was to preserve the density i.e. vertical distance between the spawn objects while incrementing the speed, and then write a formula. How did you come up with it? I mean how did you know that there has to be some constant number involved? I am sorry if it is a trivial question to you, but it is not for me. I am asking out of curiousity. Thank you a LOT!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you build a graph with those values you provided, you'll see that it looks similar to y=1/x function. Only instead of "1" there should be a much bigger value.

  • Brilliant! The simple things are the hardest. Not to mention the really hard. Thanks hundreds of times!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)