# Different array element order in PIE and Build

**URL:** <https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527>\
**Category:** Platform & Builds\
**Tags:** target-point, build, pie, unreal-engine, Array, question\
**Created:** [January 20, 2021, 3:01pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527 "2021-01-20T15:01:19Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 3:01pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/1 "2021-01-20T15:01:19Z")

</div>

Hello everyone.

I’m having a difficult time working around my problem, and here it is:

I have a Widget BP that stores Target Point actors on Initialize . I then get their transform and set the character location to each of the target points respectively upon button click.  
The problem is - It works perfectly in PIE while in build/standalone game it just breaks and teleports to the wrong locations. When I print the array element names I can see that the order changes in Standalone.  
I do presume the array order based on the first actor created and then duplicated around the level. So the second actor in the array is the second Target Point duplicate, etc.

I’ve come to learn that there’s a different execution order in Build and PIE, but not sure if it’s related to me issue.

I tried storing the target points in play controller, game instance, game mode, nothing helps.

I’d like to learn of better, smarter ways of doing this, or just any fix.  
Thanks!

 ![327652-capture1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/8/b28e719bc84bfd8355201d01c0f3bd948872d14c.jpeg)

 ![327653-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/9/1093dddfc1417e2089dd7aefd098944363f5dcb7.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 3:08pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/2 "2021-01-20T15:08:40Z")

</div>

Hi - you can’t rely on the ordering, you have to make it.

If the target point actor is a BP, you can put an int in it, if they’re just actors, you can set a tag with an int. Then grab the array and sort it by the int.

That way, you always know which order they’re coming in…

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 3:17pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/3 "2021-01-20T15:17:30Z")

</div>

Hi, Thanks for the reply.

Can you elaborate how I can achieve this via direct communication? I don’t quite understand.  
Images will be more than welcome!  
More specifically - If I make variable of type Target Point array - it won’t let me set the reference actors in the widget BP.

![327643-asd.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/c/3cc96332971fa3da357040c9afe15f6b5b0e70bd.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 3:21pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/4 "2021-01-20T15:21:59Z")

</div>

Are they meshes or blueprints?

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 3:24pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/5 "2021-01-20T15:24:47Z")

</div>

I just use Target Point Actors ideally. but I created a BP of type Target Point with int variable “ID” - following your first reply. Still can’t get it right

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 3:33pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/6 "2021-01-20T15:33:00Z")

</div>

I will get back shortly…

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 4:17pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/7 "2021-01-20T16:17:50Z")

</div>

I literally just fixed it by naming the first Target Point actor from “Target Point” to “Target Point1” to help UE4 sort the order.

![327657-asdasd.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/1/2b16be1d1610b2eb57a03a69c88679b3d32547db.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 5:33pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/8 "2021-01-20T17:33:40Z")

</div>

That might work, but I don’t think it’s a guarantee.

I’ll come back ( had some stuff to do ) …

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 7:03pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/9 "2021-01-20T19:03:38Z")

</div>

Alright thanks, looking forward to your solution.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 7:11pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/10 "2021-01-20T19:11:33Z")

</div>

Ok. If you’re going to put the build anywhere remotely important, don’t rely on asset names 🙂

This is how to get them by ID. So I made target point BPs. They’re just a target point with an ID:

 ![327685-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/4/fa47d9a2fdf8413b3154425f8b941bb11f87ca10.jpeg)

You can set the ID in level:

 ![327686-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/7/cd7f976869bbee7f66be2ead87f67f4cb92db0d1.jpeg)

Somewhere ( I did level BP ):

 ![327687-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/7/e97a7876212497289dfc7bc79b9254949cf4974b.jpeg)

Function is a bit of a fiddle, posting that separately.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 7:15pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/11 "2021-01-20T19:15:01Z")

</div>

Function goes like this:

 ![327689-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/1/651ad1db8ef5d497c7afeaf05838a3936cd7806b.jpeg)

BUT: there are some things that need to be set. Two local variables:

![327690-screenshot-5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/d/eed1b9bc303ed90a490c0d9fa301241cb2b378d2.jpeg)

One is just the found target point BP, the LowestID variable needs a default that is higher than you’ll ever use. I set this to 1000.

AND, the array coming in needs to be ‘by reference’ for it to work:

 ![327701-screenshot-6.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/e/3/4e39f335034fc952326c60421c9b8461918acdca.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 7:15pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/12 "2021-01-20T19:15:25Z")

</div>

The end 🙂

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 20, 2021, 7:21pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/13 "2021-01-20T19:21:19Z")

</div>

Thanks a lot for your effort! I’ll do the same.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [January 20, 2021, 7:23pm UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/14 "2021-01-20T19:23:20Z")

</div>

No worries - tell me if you get stuck…

---

<div class="post-metadata">

**Author:** ![Omri1324](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Omri1324](https://forums.unrealengine.com/u/Omri1324)\
**Post date:** [January 21, 2021, 7:12am UTC](https://forums.unrealengine.com/t/different-array-element-order-in-pie-and-build/477527/15 "2021-01-21T07:12:19Z")

</div>

I literally just fixed it by renaming the first actor in the world outliner to be consistent with the numbers.

![327657-asdasd.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/b/1/2b16be1d1610b2eb57a03a69c88679b3d32547db.jpeg)

I changed the first Target Point from “Target Point” to “Target Point1”. Now UE4 knows the order.

-.-
