PROBABLE TRAIN
PROBABLE TRAIN

Easy Parallax Stars

Easy Parallax Stars

Don't these stars look great

I spent a long time messing around with chunks, loading, unloading, pooling, etc. before a friend suggested I came up with a much simpler way of getting parallax stars working easily.

Generate a load of random points in a square, each with a random z-value. Scale each point's speed according to the z-value to simulate the parralax (this way you can have as many layers of parallax as you want and to add more you can just increase the range of the z-value). Whenever a star leaves the screen, just spawn it in on the opposite side of the square. As long as your square is slightly bigger than the screen size then that's it, amazing-looking amazingly simple parallax stars. If you scale the star speed in the opposite way i.e. closer stars go faster then you get a king of underwater-y effect. Could be a nice look for a diving game.

13