x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to identify an 'Instanced Static Mesh'-instance by Index after 'Remove Instance'

Hi,

i am having a problem with removing specific instances of a grid of instanced static meshes by a given X-Y-grid-position, because they lose their indices after using the 'Remove Instance'-Node in blueprints.

For the first remove this is fine, because all instances still have their original index, but by removing one, all other instances with a index higher than the one which has been removed seem to get their indexes decremented by 1 so that there are no empty index-numbers in the array.

So if i remove the instance with the index 0, the prior instance with index 1 gets index 0 and so on. This is a problem for me, because all instances have their fixed location in a X/Y-grid-system, but their indices aren't a key to identify any of them after all their indices got shifted.

For Example this is a 3x3 grid of instances represented by their index:

2 5 8
1 4 7
0 3 6

if i remove the instances with index 0 (X:0, Y:0), 4 (X:1, Y:1) and 6 (X:2, Y:0) it looks like this:

1 3 5
0 x 4
x 2 x

small x indicates where an instance has been removed.

So if i now want to remove instance at X:1 Y:2, it's very hard to reconstruct which index it has. I have to calculate how many instances have been removed before and after every instance to guess their new index.

Because indices are supposed to identify something it seems not logical to me, that the instances get their indices changed. Am i misunderstanding how the indices work and how to access them correctly or is there any workaround to find out which instance has which index after several of them have been removed?

Product Version: Not Selected
Tags:
more ▼

asked Mar 30 '16 at 12:42 AM in Using UE4

avatar image

Axzz
33 2 6 8

avatar image ThomSip Apr 08 '16 at 02:38 PM

I'm wondering this myself too. I currently have a grid of structs setup, with an index reference for the instance linked to Structs. The visual representation of this grid are a bunch of instances of 3 separate instanced static mesh components.

Lets say I change a tile from FLOOR to WALL I than loop through my array of structs, whenever he sees a FLOOR, he checks if the index of that tile is higher than the the index of the tile I just changed. If so, it removes 1 from structs instance-Index to compensate for the array shifting.

This obviously is a horrible method. However, it was the only way I got it to work so far. Help greatly appreciated!

avatar image Axzz Apr 21 '16 at 12:41 PM

This is the same (horrible) method which i considered. But i am still hoping that the changing indices is a bug and it will change in some near future engine version. that part of my project is on hold since then so the blueprints get no unnecessary complex workarounds.

i am not sure if the issue should be reported as a bug or if it is working as intended for some reasons and i am just using it in a wrong way.

can somebody clarify that?

thanks!

avatar image haimat Jan 02 '19 at 05:32 PM

This is the same horrible method I am using in my project now, with UE4.21 - is there still no better approach to this?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I just have an array that runs in tandem with the instances. When I add an instance, I add an item to the array. When I delete an instance, I delete that index also from the array. The array can contain indexes, id numbers, references... whatever you need to link each instance to something else. So, if you need to get an instance for object x, you find the link to object x in the array, then the index you found will match to the instance index you're looking for.

more ▼

answered Aug 02 '17 at 11:00 AM

avatar image

Deanh22a
6 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi ! Just want to mention - Alex and Ian talk about this array behavior in Training Stream around 15 min. mark

https://www.youtube.com/watch?v=bOjYP-c4qhA&t=779s

more ▼

answered Mar 22 '18 at 05:42 PM

avatar image

TVinforest
459 15 13 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question