#Execute code at set interval with no frame dependency

1 messages · Page 1 of 1 (latest)

copper sand
#

Hi, I'm working on a bullet hell game. I've been struggling to figure out whether to run code in fixedupdate, use invokerepeating, use coroutine or other work arounds. Basically, I'm trying to instantiate projectiles at a set interval, but variation in framerate destroys the perfection of the patterns.

I've considered other solutions, such as making the position of projectiles be based off of a mathematical equation rather than something dependent on deltatime, but this is rather limiting as some projectiles would require movement that would be far too complicated to be written as an equation.

Any suggestions?

mental scroll
#

seems like fixedupdate could work as a simple but limited fixfor that, it'd mean you could only have them be so dense

copper sand
#

it sounds intimidating but afaik it's probably the most solid solution

radiant kraken
#

Fixed update is one part of it but for a bullet hell and getting perfect mathematical patterns etc you need to go further. You need to instantiate the bullets and then move them to where they would be if they had spawned at the precise wall clock time you intended and then moved in the way you intended for the elapsed time since then. All in the spawning logic

mellow topaz
#

If you're concerned about the complexity of math formulas id suggest looking at the animation curve struct to see if that would work for you. You can use it as an arbitrary function that you can define the shape of in editor.