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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

4.17 Instance static mesh wrong index when removed

Hello,

When I moved my project to 4.17 I realize that instance static mesh stopped working. It seems like invalid index is returned if one of the instances are removed. It only happens for specific instances.

To reproduce:

1.Create instances
2.Use on component begin overlap and try to destroy from SwapResult->HitItem;
3.Do it for few elements - Index become invalid and at some point instances are not removed anymore.

Workaround is to initialize all instances: Remove Instance, Remember all instances, Clear Instances, Add all instances.

Regards,
Tefel

Product Version: UE 4.17
Tags:
more ▼

asked Sep 23 '17 at 07:12 PM in Using UE4

avatar image

Tefel
24 3 8 13

avatar image CriErr Sep 24 '17 at 02:57 AM

Can you post a screenshot of step 2 and 3?

avatar image Tefel Sep 24 '17 at 09:36 AM

https://imgur.com/a/84POY It seems it works only in specific order from the highest to the lowest index.

avatar image CriErr Sep 24 '17 at 10:43 AM

Nah, it removes the component index of which you requesting

     // remove instance
     PerInstanceSMData.RemoveAt(InstanceIndex);

You sure, that sweep result "hit item" actually returns the index of a SM instance you hit?

avatar image Tefel Sep 24 '17 at 01:45 PM

Yes blueprint I showed is not working anymore. Indexes are incorrect after first removal. You need workaround I suggested to make it work.

avatar image CriErr Sep 24 '17 at 08:24 PM

I've checked your video, seems like it works just fine. Here the description of remove node.

     /** Remove the instance specified. Returns True on success. Note that this will leave the array in order, but may shrink it. */
avatar image Tefel Sep 24 '17 at 09:16 PM

In the video it's not removing anything. It is returning 0 indexes. It is not removing elements anymore after switch from 4.16 to 4.17 but maybe it's intended behavior.

avatar image CriErr Sep 25 '17 at 12:02 AM

Ok, I see now.

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

2 answers: sort voted first
more ▼

answered Sep 24 '17 at 03:18 PM

avatar image

Tefel
24 3 8 13

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

This is because each time you remove an item, the total array of those instances is re-sized. So if you have 50 blocks there and the first one is "0", if you remove that "0" the next block in line will then become the new "0" and the total array will become 49 instead of 50. I am dealing with a bug caused from this same issue.

In my game, a player can mine ores. Lets say there are 5 iron ore nodes on my map. If a player mines an iron ore, my code properly removes that specific iron node from the game for 20 seconds. After 20 seconds, the iron ore respawns. If I wait for the ore to repsawn before I mine another ore, the whole process works fine, but if I mine an ore while waiting for another ore node to respawn, it will remove the wrong ore node or not remove one at all because the array has been changed from its original state.

I have no idea on what a workaround would look like, but that's the problem.

more ▼

answered Mar 13 '19 at 07:37 PM

avatar image

DK Buzzin
11 2 6

avatar image Tefel Mar 13 '19 at 07:44 PM

That was a bug in 4.16/4.17 when removing ISM it was not giving you index of correct instance. It always should in my opinion, otherwise you would never know instance you are interacting with.

But it was fixed so no worries :)

avatar image DK Buzzin Mar 13 '19 at 08:00 PM

Okay I see. Looking at my problem a little harder revealed that the indexing isn't the problem for me. When my instanced static meshes are set to respawn, they use two stored variable values; instance index & instance transform. So my problem stems from, if i start mining a new node before the first one respawns, I am updating those two variables so I will try to respawn in the location that I am currently mining not its original location.

(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