Misplaced Instanced Static Mesh

I wasn’t quite sure what to name this as the issue is rather peculiar to say the least. I’ve made a generator which generates a grid of instanced static meshes(using the hierarchical one so I can use the cull distance later if needed).

However, there is always one instanced static mesh that is misplaced, put inside my “walls”. I’ve gone through my math several times and it shouldn’t be happening. What’s even more peculiar is that sometimes it will randomly disappear when that one instance goes out of view.

Also, if I enter debug camera mode - it will disappear right away. Any ideas as to what might be going on here?

I’m on 4.12.3.

Video Example: https://streamable.com/ms60

The grid of interest is the green one at the bottom left.

Hi,

  • Can you show me a screenshot of how you are populating your instanced meshes?

  • Are you spawning the meshes at runtime or in the construction script?

  • What steps can I take to reproduce this on my end?

It’s rather large so I couldn’t fit all of it, but I could get what should be relevant.

This function is executed using the BeginPlay event.

I’m not quite sure as to how you would go about to re-produce this issue, really, as I’ve no idea what’s causing it. The fact it disappears when I enter debug camera makes it seem like it’s some bug with the rendering of instanced meshes…?

Have you tried running this in the construction script instead of on begin play to see if there is a difference? Additionally, try adding a check before mesh placement for another instance in the location being placed to see if that causes the issue to halt. I don’t think the walls portion of the script is going to be the problem, it looks more like a green cube is being placed after the fact, which could happen if it is not checking for a tile that is already placed first.

Hey, sorry for the delayed response. I tried hooking it up using construction script instead and I see the same results.

However, whilst in the viewport it looks fine.

It still behaves the same, upon entering debug camera the instance is instantly removed.

I don’t think it’s an instance being wrongly placed as it’s removed as soon as I enter debug camera mode or the grid going out of view.

If necessary I can provide you with the project or alternatively the .uasset file(s) themselves - whichever is more convenient for you*(it’s hasn’t got any significant content yet, so it’s relatively small)*.

Also a quick off-topic question; are there any performance differences to using construction vs BeginPlay? The reason I went with BeginPlay is due to the editor generating the entire grid every time I compile it, which got a bit annoying after a while.

Hello,

If you would like to provide the project so that we could take a closer look, you could do so here or in a private message to me on the forums. This can be done with a google drive or dropbox link.

Additional information for the second question:

The performance difference would be that, all of the grid generation would be done ahead of time when using the construction script. This will take more memory up front and less taxing at runtime. On the other hand, if you use begin play this will mean that the grid is made at runtime. This means that it could have an impact on performance during generation depending on complexity.

I’ve sent you a PM with the project files. Hopefully y’all might be able to figure out what’s going on. :slight_smile:

Hello,

After taking a look at your project it appears that your issue stems from the “Empty spaces” that you are providing to the instanced meshes. If you run a check to see if the vectors that are given are within the “emptyGridVectors” array, you will find that some of them are not within the array. I have provided an example below on how I was able to workaround the issue. You could use this method if you want, however you may want to take another look on how you are placing your instanced meshes. I hope that this information helps.

Example:

In this example I check to make sure that the values that are passed to the instanced meshes for their location are within the array. This is done by making sure that find item does not return a -1.

Make it a great day