Asteroid spawning implementation

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
jaylawl
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sat Nov 23, 2024 10:14 am
Contact:

Asteroid spawning implementation

Post by jaylawl »

What is known about this topic?

I would love some deeper, technical knowledge about asteroids. I'm especially interested in asteroid spawning behaviour. I'm sure all of you have already observed that:
- asteroids seem to mostly spawn in front of the platform
- few asteroids spawn in such a way that they approach the sides of the platform
- no asteroids (other than harmless chunks) will ever hit the back side of the platform, where engineers usually place their thrusters

However, these are merely observations. Are there any facts available on this? Preferably facts extracted directly from the coding of the game. This would help a lot with detailed platform building / balancing.
mmmPI
Smart Inserter
Smart Inserter
Posts: 5048
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Asteroid spawning implementation

Post by mmmPI »

That seem a good topic for a future FFF, given the several rounds of optimizations that occured, and the cryptic curves on the factoriopedia that leaves players wondering if the m is for minutes or meter endlessly.

I think your observations are incomplete,as you had some luck for now, but one time your ship will not be moving and you will encounter asteroids from all sides , including the back !

This just doesn't occur on Nauvis, where only harmful asteroids exists, but otherwise, they do spawn from all direction when the platform doesn't move, such as a static platform orbiting above a planet that isn't Nauvis. ( This is visible on editor if you increase speed a lot, it look like your platform attract them like a lightbulb with insects).

When travelling it's a bit particular because i think then no asteroids will ever "catch up" with your ship. Those that are spawn "behind" it, will just be left behind, whereas there will constantly "new" asteroid spawned in the front of your ship". So it look like what you observed. Maybe also the game just doesn't spawn any in the back for optimization/ common sense purposes.

But when you "stop" a ship , it start to drift backward if it happens during the first half of the trip, and this is something that could cause some asteroid to seemingly come from the back.
HadesSupreme
Long Handed Inserter
Long Handed Inserter
Posts: 81
Joined: Fri Nov 03, 2017 3:53 pm
Contact:

Re: Asteroid spawning implementation

Post by HadesSupreme »

I've definitely taken damage on my sides. I suspect it was from an asteroid that was destroyed and one of the pieces gained a horizontal velocity.
jaylawl
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sat Nov 23, 2024 10:14 am
Contact:

Re: Asteroid spawning implementation

Post by jaylawl »

I love the idea of having a deep dive FFF about this.

The observations i made and listed in the OP were pretty much exclusively about stationary platforms. Of course no platform is in danger of being hit from the back while moving at any speed. And the faster you are travelling the less likely your sides are to be hit by anything (assuming a design that is mostly a flat line going between the front and the back).

But asteroids will most certainly spawn with a sideways velocity and hit your sides unless they are defended. Far fewer than are coming in the front, sure - but the sides require defense.

Some numbers on this matter by the devs in an FFF would be fantastic.
Georodin
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sat Jan 04, 2025 5:25 am
Contact:

Re: Asteroid spawning implementation

Post by Georodin »

Yeah, I noticed when building just in one Dimension really flat, then it will mess with the spawn direction of the asteroids when stationary.
Like my ship is atm 7:1 in width and the asteroids only spawn with left and right velocities.
Guess the lower the ratios, the better? Idk yet, think meta is slow flying between planets for farming, so a wider width ratio is beneficial.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3272
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Asteroid spawning implementation

Post by BlueTemplar »

mmmPI wrote: Fri Dec 06, 2024 9:36 pm [...]

I think your observations are incomplete,as you had some luck for now, but one time your ship will not be moving and you will encounter asteroids from all sides , including the back !

This just doesn't occur on Nauvis, where only harmful asteroids exists, but otherwise, they do spawn from all direction when the platform doesn't move, such as a static platform orbiting above a planet that isn't Nauvis. ( This is visible on editor if you increase speed a lot, it look like your platform attract them like a lightbulb with insects).

When travelling it's a bit particular because i think then no asteroids will ever "catch up" with your ship. Those that are spawn "behind" it, will just be left behind, whereas there will constantly "new" asteroid spawned in the front of your ship". So it look like what you observed. Maybe also the game just doesn't spawn any in the back for optimization/ common sense purposes.

But when you "stop" a ship , it start to drift backward if it happens during the first half of the trip, and this is something that could cause some asteroid to seemingly come from the back.
Are you sure about this ?

I'm in the process of designing my first stationary platform
(that wasn't just a slap-dash attempt to get a trickle of space science over Nauvis)

and it does seem that even for a platform that never moved,
space has a «direction», and so asteroids seem to never (?) spawn in the South,
never (?) going Northwards :
stationary_platform-asteroid_direction-chunk_numbers.jpg
stationary_platform-asteroid_direction-chunk_numbers.jpg (149.85 KiB) Viewed 490 times
(The few chunks that were caught in the back would have been from East and West,
and I made sure that all of the platform was built and operational with hardly any difference between the 8 collectors.)

EDIT : correction, it does seem like that Nauvis is different, when it comes to those harmless chunks - they do also come from the South going Northwards... Nauvis might be exceptional ??

(In fact if you look at the space dust and non-interactable-with asteroids in the background, you can see both of them moving in a Southwards flow, even at zero platform speeds !
Which I guess might be a very simplistic way to simulate «orbital mechanics», with the referential being one with « orbital speed» being zero ?)

I'm going to try to leave the back of my platforms completely defenceless (except by accident)
(including for moving platforms)
and see what happens !
BobDiggity (mod-scenario-pack)
Yess
Burner Inserter
Burner Inserter
Posts: 7
Joined: Sun Jul 13, 2025 7:47 am
Contact:

Re: Asteroid spawning implementation

Post by Yess »

mmmPI wrote: Fri Dec 06, 2024 9:36 pm That seem a good topic for a future FFF, given the several rounds of optimizations that occured, and the cryptic curves on the factoriopedia that leaves players wondering if the m is for minutes or meter endlessly.

I think your observations are incomplete,as you had some luck for now, but one time your ship will not be moving and you will encounter asteroids from all sides , including the back !

This just doesn't occur on Nauvis, where only harmful asteroids exists, but otherwise, they do spawn from all direction when the platform doesn't move, such as a static platform orbiting above a planet that isn't Nauvis. ( This is visible on editor if you increase speed a lot, it look like your platform attract them like a lightbulb with insects).

When travelling it's a bit particular because i think then no asteroids will ever "catch up" with your ship. Those that are spawn "behind" it, will just be left behind, whereas there will constantly "new" asteroid spawned in the front of your ship". So it look like what you observed. Maybe also the game just doesn't spawn any in the back for optimization/ common sense purposes.

But when you "stop" a ship , it start to drift backward if it happens during the first half of the trip, and this is something that could cause some asteroid to seemingly come from the back.
Asteroid spawning definitions set specific spawn angles for a stationary platform, for each type of asteroid.

IIRC, for a platform moving forward, asteroids always spawn from the northern edge of the map, with a vertical downward velocity based on platform speed, and random, small variation in horizontal velocity. I don't know about a platform moving backward, though.

When stationary, spawned asteroids move mostly towards the platform, with slight variation in the angle of drift (I couldn't dig up data on this one), so some asteroids will move directly toward the platform hub, while others may miss entirely.

See AsteroidSpawnPoint in the Lua docs, SA prototype definitions for the asteroid spawns, and the attached image, made with reference to the prototype data.
Attachments
Factorio Asteroid Spawns.jpg
Factorio Asteroid Spawns.jpg (87.24 KiB) Viewed 456 times
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3272
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Asteroid spawning implementation

Post by BlueTemplar »

Data mining to the rescue ! :P
BobDiggity (mod-scenario-pack)
eugenekay
Smart Inserter
Smart Inserter
Posts: 1049
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Asteroid spawning implementation

Post by eugenekay »

Platforms in Interplanetary space (with no Thrust) will travel at -10.00km/s in "Reverse" (the Stars parallax effect is reversed compared to forward travel); Asteroids & Chunks appear to spawn at the same Rate & Angle as if the Platform was "Stopped" at a Planet. In a hour-long Map Editor Test between Vulcanus & Nauvis (at x64 Tick speed) this setup did not have any Kills registered by the rear-center Gun Turret. The side & forward Turret Kill Counts are fairly normally distributed.
04-26-2026, 13-39-39.png
04-26-2026, 13-39-39.png (956.88 KiB) Viewed 403 times
Depending upon Platform Geometry (ie, C-shaped or otherwise non-rectangular) it is possible for an Asteroid following a Tangent course from an edge to strike the "Bottom edge". So you really should maintain full turret coverage, for safety. :lol:
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3272
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Asteroid spawning implementation

Post by BlueTemplar »

For such a rare occurrence, a wall might be enough ?
BobDiggity (mod-scenario-pack)
mmmPI
Smart Inserter
Smart Inserter
Posts: 5048
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Asteroid spawning implementation

Post by mmmPI »

BlueTemplar wrote: Sun Apr 26, 2026 1:36 pm
mmmPI wrote: Fri Dec 06, 2024 9:36 pm [...]

I think your observations are incomplete,as you had some luck for now, but one time your ship will not be moving and you will encounter asteroids from all sides , including the back !

This just doesn't occur on Nauvis, where only harmful harmless asteroids exists, but otherwise, they do spawn from all direction when the platform doesn't move, such as a static platform orbiting above a planet that isn't Nauvis. ( This is visible on editor if you increase speed a lot, it look like your platform attract them like a lightbulb with insects).

When travelling it's a bit particular because i think then no asteroids will ever "catch up" with your ship. Those that are spawn "behind" it, will just be left behind, whereas there will constantly "new" asteroid spawned in the front of your ship". So it look like what you observed. Maybe also the game just doesn't spawn any in the back for optimization/ common sense purposes.

But when you "stop" a ship , it start to drift backward if it happens during the first half of the trip, and this is something that could cause some asteroid to seemingly come from the back.
Are you sure about this ?
Mmmm somewhat, as it happened to me to have a platform damaged on the back :(

BlueTemplar wrote: Sun Apr 26, 2026 1:36 pm EDIT : correction, it does seem like that Nauvis is different, when it comes to those harmless chunks - they do also come from the South going Northwards... Nauvis might be exceptional ??

I'm going to try to leave the back of my platforms completely defenceless (except by accident)
(including for moving platforms)
and see what happens !
Indeed it would seem my observation is only valid in Nauvis, no larger asteroid than the harmLESS ones would spawn at 360°, HOWEVER, this doesn't mean your platform will only receive asteroids from those angles.

There are at least 2 things that you also need to factor in imo :

1) your platform if moving can "stop" a few seconds after an asteroid was spawned in an horizontal direction, with the speed you will pass it a little and it may appears to come from an "illegal" angle

2) you will destroy some asteroids that will split in smaller ones, ricochet may happen and cause the pieces to appear to come from an "illegal angle" too.

I think that's how i got my platform damaged now that i look at the explanations on spawning angles.
Yess wrote: Sun Apr 26, 2026 3:16 pm When stationary, spawned asteroids move mostly towards the platform, with slight variation in the angle of drift (I couldn't dig up data on this one), so some asteroids will move directly toward the platform hub, while others may miss entirely.
thanks for the additionnal information, my answer was quite old and incomplete or misleading, the editor mode allow to set speed to x64, and at this speed it's "easy" to see the platform as a magnet / gravity well for asteroids, IN NAUVIS ORBIT, here you can see all the harmless chunk converging to the hub, including those spawned at 6 o'clock for the ship.

I wasn't sure asteroid did spawn from the back when travelling , it's not the case, probably an optimization thing, but imo it doesn't mean it's safe to leave the back of the ship unprotected. Such considerations may matters differently following the shape and speed of one's spaceship, i would test differently a very long and slow horizontal ship like a brick or a space rake and a more classic "fast cigar" or "needle".
Check out my latest mod ! It's noisy !
Post Reply

Return to “Gameplay Help”