# PerInstanceRandom and Instanced Static Mesh bug.

**URL:** <https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501>\
**Category:** Rendering\
**Tags:** UE4-17, Instanced-Mesh, unreal-engine, bug-report, Blueprint, question\
**Created:** [August 11, 2017, 6:20am UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501 "2017-08-11T06:20:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naifu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naifu](https://forums.unrealengine.com/u/Naifu)\
**Post date:** [August 11, 2017, 6:20am UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/1 "2017-08-11T06:20:02Z")

</div>

In 4.17, unlike 4.16.3, “PerInstanceRandom” node in material doesn’t change value with instances of Instanced static mesh component, if they are NOT added in construction script or directly to component.  
Reproduction steps:

1. New project or any other.
2. Create new material with PerInstanceRandom connected to “Emissive Color”. Will have to set it to use with Instances as automatic doesn’t seem to work.
3. Create new actor and connect “Add Instance Static Mesh Component” to “Event BeginPlay”.
4. Set mesh to anything and material to the one created in “2.”.
5. After component, connect multiple “Add Instance” nodes with random locations or use for loop.
6. Observe as all instances have the same color.

If you do this in Construction script or directly click + to add instances to mesh component, PerInstanceRandom works. If you than use Update Instance Transform on the same instances PerInstanceRandom doesn’t work.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [August 12, 2017, 8:58pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/2 "2017-08-12T20:58:50Z")

</div>

Hello Naifu,

Thank you for reporting this issue. I’ve reproduce the issue and entered a bug report for the issue. You can use the following link to track the issue’s progress: [UE-48340](https://issues.unrealengine.com/issue/UE-48340).

Have a nice day!

---

<div class="post-metadata">

**Author:** ![HeartMachine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HeartMachine](https://forums.unrealengine.com/u/HeartMachine)\
**Post date:** [September 16, 2017, 1:35am UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/3 "2017-09-16T01:35:44Z")

</div>

hey we’re blocked on this. any guidance when 4.17.2 will be released?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_565e242f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_565e242f](https://forums.unrealengine.com/u/anonymous_user_565e242f)\
**Post date:** [September 18, 2017, 4:59pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/4 "2017-09-18T16:59:19Z")

</div>

4.17.2 should be release really soon.

---

<div class="post-metadata">

**Author:** ![Naifu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naifu](https://forums.unrealengine.com/u/Naifu)\
**Post date:** [November 4, 2017, 12:40pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/5 "2017-11-04T12:40:03Z")

</div>

After 4.17.2 and 4.18 fixes I have noticed another strange behavior with PerInstanceRandom.

HISMC - Hierarchical Instanced Static Mesh Component

ISMC - Instanced Static Mesh Component

If you rotate HISMC, it will reset/change PerInstanceRandom value to all Instances, unless you disable collisions for HISMC. ISMC doesn’t have this behavior.  
If you update instance transform of an instance its PerInstanceRandom value is reset/changed for HISMC and ISMC.

I have tested this with 4.17.2 and 4.18 release versions.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [November 6, 2017, 5:12pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/6 "2017-11-06T17:12:01Z")

</div>

Hello Naifu,

Thank you for following up and reporting this issue. I’ve entered a new bug for this particular issue which can be found and tracked here: [UE-52049](https://jira.it.epicgames.net/browse/UE-52049)

Have a good one!

---

<div class="post-metadata">

**Author:** ![Naifu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naifu](https://forums.unrealengine.com/u/Naifu)\
**Post date:** [January 19, 2018, 11:16am UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/7 "2018-01-19T11:16:31Z")

</div>

I have tested the fixes in 4.19 preview 1 and rotating HISMC seems to be fixed. However, with HISMC there is still a problem if you have more instances spawned (at least 6) and you try to get certain instances transforms, add random values to them and update it. What happens is that sometimes two or more instances swap their per instance randomized colors. It is really random and higher sample size or the longer I am modifying transforms makes it worse.

---

<div class="post-metadata">

**Author:** ![Naifu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naifu](https://forums.unrealengine.com/u/Naifu)\
**Post date:** [January 24, 2018, 10:02am UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/8 "2018-01-24T10:02:17Z")

</div>

Also adding or removing an instance resets PerInstanceRandom of all instances in HISMC.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_565e242f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_565e242f](https://forums.unrealengine.com/u/anonymous_user_565e242f)\
**Post date:** [January 26, 2018, 8:22pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/9 "2018-01-26T20:22:13Z")

</div>

Hi  
You were right for the Add causing issue with the RandomStream, unfortunately i couldn’t repro for the Remove and the code would not allow this either.

As for your other issue, keep in mind that adding/removing instance will alter the orders of the instances in your array, so it might feel like it’s not doing what you expect.

---

<div class="post-metadata">

**Author:** ![Naifu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Naifu](https://forums.unrealengine.com/u/Naifu)\
**Post date:** [January 26, 2018, 11:05pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/10 "2018-01-26T23:05:59Z")

</div>

You are right, removing a random instance changes orders in both ISMC and HISMC. (Instances change color.) Additionally, if I am removing only the last instance in ISMC, order doesn’t change contrary to HISMC where it does.

However, adding an instance changes color/order only in HISMC.  
Also, I have noticed that sometimes when updating Transform in HISMC, instances also swap colors/orders.  
\*Now in 4.19 Preview 2

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7765a052](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7765a052](https://forums.unrealengine.com/u/anonymous_user_7765a052)\
**Post date:** [May 14, 2019, 5:47pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/11 "2019-05-14T17:47:14Z")

</div>

I’m running against the same issue, maby removing a instance should just leave the array empty on that location and fill it up when something is added again to not mess with ordering? or somehow copy and past the per instance values to the new seed location.

---

<div class="post-metadata">

**Author:** ![wickerman123](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/wickerman123/32/1198875_2.png) [@wickerman123](https://forums.unrealengine.com/u/wickerman123)\
**Post date:** [December 2, 2019, 5:43pm UTC](https://forums.unrealengine.com/t/perinstancerandom-and-instanced-static-mesh-bug/401501/12 "2019-12-02T17:43:09Z")

</div>

This issue is marked as fixed in 4.19 but it is **still affecting 4.23.**

Can this issue be updated?

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-52049)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.
