My game is a scroller where the player has to dodge all of the incoming objects to pass the level, however as the level increases so does the amount of objects that spawn per level, below is the general idea of how many objects i want to spawn per level, i want the amount of levels to be unlimited therefore i need to know how to write down this pattern in a math equation.

level 1 = 5 objects

level 2 = 10 objects

level 3 = 15

level 4 = 20

level 5 = 25

(this is where i got lost)

level 6 = 35

lvl 7 = 45

lvl 8 = 55

lvl 9 = 65

lvl 10 = 75

so the idea is every 5 levels, the accumilated objects per level increases by an extra 5. so levels 11-15 will increase by 15, lvls 16-20 will increase by 20 and so on…

So the other two answers will work (I think) but require you to carry forward your multiplier from the previous level, which is quite simple (check out DontDestroyOnLoad, and iirc static variables)

If for some reason you can take forward the multiplier from the previous level then this should work:

var obstacles : int;
var level : int;
private var n : float;
n = Mathf.Floor ((level-1)/5.0);
obstacles = 5*(level*(n+1)-(2.5*n*(n+1)));

Apologies if this is incorrect, I’m writing on my phone!