|
I'm making a game where the player character moves toward the right constantly. i have obstacles and coins being spawned in the players path using InvokeRepeating(spawn,0,random.range(#,#)). the problem is that it picks a number and wont let me change that number during the game. i thought if i put it as "InvokeRepeating(spawn,0,(random.range(#,#) + spawnRate)" it would change when i changed the spawnRate. Is there a way to do this without rewriting the whole thing?
(comments are locked)
|
|
I assume by # you mean an actual number, and by actual number, I mean a floating-point number. As long as those two numbers are different, it should pick a new number each time. Assuming this is in an Update function, not Start or Awake. Which is what I'm guessing you did. Replace InvokeRepeating in Start with Invoke in Update, putting your random value there. Actually, you probably should use a 'timer'. Something like:
(comments are locked)
|
