# How can I create an array of objects within another object properly in Blueprints in Unreal Engine 5?

**URL:** <https://forums.unrealengine.com/t/how-can-i-create-an-array-of-objects-within-another-object-properly-in-blueprints-in-unreal-engine-5/1813047>\
**Category:** Blueprint\
**Tags:** dependencies, object, child-actors, unreal-engine, Array, Blueprint, question\
**Created:** [April 20, 2024, 8:07pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-array-of-objects-within-another-object-properly-in-blueprints-in-unreal-engine-5/1813047 "2024-04-20T20:07:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huyfrommount](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Huyfrommount](https://forums.unrealengine.com/u/Huyfrommount)\
**Post date:** [April 20, 2024, 8:07pm UTC](https://forums.unrealengine.com/t/how-can-i-create-an-array-of-objects-within-another-object-properly-in-blueprints-in-unreal-engine-5/1813047/1 "2024-04-20T20:07:11Z")

</div>

I’m encountering a particular issue. Let’s say we have a Car class and a Wheel class (both being separate classes as per my requirements). I associate wheels with cars, and in the editor, everything functions correctly; each car has the appropriate wheels, even with multiple cars. However, when I build the game, there’s an issue where CarA ends up with wheels from CarB, and vice versa.

Here’s how I initialize it: I gather all actors of the Car class and all actors of the Wheel class. Then, I iterate through each car in the array using a foreach loop. Inside this loop, I have another loop with four iterations (representing the number of wheels on a car). Within this nested loop, I add each wheel from the array of all wheels to the array of wheels for the current car. I increment the counter to ensure each set of wheels is assigned to the correct car (something like this: [array of objects posted by anonymous | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/sup_n6l2/) ). As mentioned, this setup works flawlessly in the editor, but I encounter discrepancies when building the game.

Note: In my scenario, I’m not explicitly dealing with cars and wheels, but the issue is analogous to what I’ve described here. Additionally, the discrepancy between the build and the editor persists.
