How can I spawn instanced static mesh through code?

Hello, I’ve got an actor class that act’s as a tile. I have a system that puts those tiles into place. When I run the game I see the actors spawn where they should but they are listing in the outliner. I see something like 5000 of these actors. Even though as a test these actors static mesh is only a single triangle. Then I ran across Rama’s instance static mesh videos and I see him spawn thousands of these cubes which appear to not only have more vertices, but also collision attached to each cube. He then uses his editor hotkey setup to link them all together under one node which appears to dramatically increase performance.

I’m curious how I would go about linking my actor list as a instanced static mesh through code. Are these additional duplicates attached to one actor as a static mesh component? Also do I need to download Rama’s plugin to be able to do this or is his a plugin for convenience within the editor? Thanks in advance!

Ya, it seems there are many problems with Rama’s work. We advise against using this author’s plugins.

who is “we” if you count more than yourself?

i would say it like this:
the engine has much improvement behind and of course some things changed…
its a great thing rama was so kind and doing all the tutorials, samples and libraries which is paired with big engagement and huge effort.

i can not count how often i learned from his stuff…
thank you rama :slight_smile:

on the other side you may be right in some ways but the thing is, it is much more effort necessary to take care over all the stuff he did for the community…
i bet he is working on his own game :wink:
hey and the tutorials are still good, you just need to know what changed or how to fix and even don’t need to be a code hero for that.

@Thumper:
Take a look on the examples… splines track in example or youtube

Instanced mesh rendering can be faster
because it requires a single draw call
when rendering an object n times
(normally that requires n draw calls).
It saves mostly CPU time (if you are
not bound by that you don’t see a
benefit). It only helps if you have at
least a few (depends on GPU/driver, a
number of 8 might be reasonable but
that might have changed) as there is
some overhead. When combing draw calls
to one you are limited to make changes
per object. The transformation matrix
can be changed, some UV and other
things. The cull mode cannot be
changed…
written by Martin Mittring from Epic (Instanced Static Mesh Bug - Asset Creation - Epic Developer Community Forums)

so in short you can use instanced mesh rendering to increase the rendering speed but its limited in functionality (shadows etc)

Actually I found This link to be very helpful. I was able to use the Hierarchical Instanced Static Mesh Component instead. It supports per instance LODing.

Also, yeah, Rama’s stuff is awesome. Very helpful!

That hasn’t been my experience, his work is top notch.

It is great, but note Rama’s own disclaimer - the plugin was written without always having access to the engine source - so therein issues exist, but only if you’re doing something different.

In our case, we were passing arrays from a VM, converting from one language to another, then using a derivative implementation of the plugin to parse the array (happens to be sparse matrix). So there were a few crashes, resulting from perhaps insufficiently delicate implementation.

On a more general note, if using a C++ Project, and compiling using VS - when disabling the plugin - a whole lot of hurt results. The plugin cripples VS for some odd reason, Windows as well - basically it is more cost effective to format and start over.

So if you play by Rama’s rules, nothing should be buggy inherently due to its mere implementation. We are currently going over the plugin, to find these sort of errors, and we hope to share the augmented work with the community and Rama.

That may be, but my question wasn’t how to use ramas plug-in, rather how one can spawn an instanced static mesh. To which I provided a link for future readers where they can find a tangential solution using something similar. I’m going to mark this answered unless someone would like to add examples or reference material that can assist others.