Advice for Creating an Asteroid Field?


I was wondering if I could get advice from someone whose a bit more intimate with UE4

My goal is to create an asteroid field consisting of thousands of asteroids, each on rotates and orbits the sun, or any other body I choose. The asteroids need to rotate. They don’t need to interact with other asteroids, but with harvesters who simply catch them.

I can set up the orbits and what not, how ever, my main issue is performance. 100 asteroids is fine, 500 is ok, but much more and things come to a crawl. I’m using instancing, but I thought that I would get more performance, though seeing as I’m updating transforms things are a bit slower. I believe I’m doing the instancing right by adding an instanced mesh component to a BP and then adding new instances, passing the component. I do get a boost when using the launch button, but it’s not too much.

What things are there, that I can do with BP, to improve performance?

What about the overhead of adding/deleting instances?

I would still need to calculate the position of several hundred/thousand object even when not in view.

Anyways, I already have a system in place that only applies the transform to the instance when within a certain distance to the camera, albeit in a sphere and not a cone, similar to adding/deleting but without actually deleting or adding them after the initial set up.

And how would I be able to go about it in terms of a cone?
Here’s what I’ve got for culling in terms of a sphere atm:

I was going to do this in my game but I haven’t got around to it, but I would look at the scene and calculate the visible area I.e. Infront of the camera then spawn asteroids in that space (cone shape) upto a certain distance, that way you only need spawn a portion of the whole asteroid field. This also has the ability to in effect turn off the field when you get too far away which is ideal.

Good luck.

Actually I think a better idea rather than deleting and spawning meshes would be to set them as hidden Ingame as this reduces the need for rendering greatly, also I think a sphere collision will be fine vs cone, but you could import a custom collision box. Coupled with your transp from system IT should improve performance.

I’ve currently got that set up as well, at least I think I have the same thing set up.
I don’t know of any other way to hide an instance other than in the materials, hooking up a PerInstanceFadeAmount node to the opacity mask and setting the cull distance in the InstanceStaticMesh component, though doing so didn’t do much.

I don’t get what you’re on about with custom collision box.

I think my main issue is with updating so many transforms that it’s causing the game to wait quite a bit, as it’s iterating and doing some math so many times and my CPU ain’t that new as opposed to my GPU. And the only way to help in that case, that I can think of, is by doing the calculating in another or several threads, but as far as I know, that is only done in C++.