# Array of tuple or array of struct

**URL:** <https://forums.unrealengine.com/t/array-of-tuple-or-array-of-struct/1228684>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, editor, question, fortnite\
**Created:** [July 14, 2023, 3:49am UTC](https://forums.unrealengine.com/t/array-of-tuple-or-array-of-struct/1228684 "2023-07-14T03:49:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clevereen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clevereen/32/728648_2.png) [@Clevereen](https://forums.unrealengine.com/u/Clevereen)\
**Post date:** [July 14, 2023, 3:49am UTC](https://forums.unrealengine.com/t/array-of-tuple-or-array-of-struct/1228684/1 "2023-07-14T03:49:36Z")

</div>

Hello we are trying to access quickly a variable that will store multiple info, that we could update.  
The following code will allow you to quickly access an array of struct(int,int)

but how can we do with a type of agent?

```auto
#SET A STRUCT
coordinates := struct:
    X : float = 0.0
    Y : float = 0.0

```

Here when we try to use the struct

```auto
OnPlayerStart:=class(creative_device):
    #=VARIABLE DECLARATION=
var CoordinateStructArray:[]coordinates =array{}

OnBegin<override>()<suspends> : void =
   TeamBalance()

TeamBalance():void=
   CoordinateStructArrayTemps:=coordinates{X :=0.0,Y:=0.0}

   set CoordinateStructArray+=array{CoordinateStructArrayTemps}

```

---

<div class="post-metadata">

**Author:** ![Clevereen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clevereen/32/728648_2.png) [@Clevereen](https://forums.unrealengine.com/u/Clevereen)\
**Post date:** [July 14, 2023, 4:34am UTC](https://forums.unrealengine.com/t/array-of-tuple-or-array-of-struct/1228684/2 "2023-07-14T04:34:05Z")

</div>

Ok found a solution after multiple attemps, here an array of struct that holds the player information:

```auto
#SET A STRUCT
PlayerInfoStruct<public>:=struct:
    playerIndex:int=0
    playerTeam:?team = false

```

Here the class

```auto
OnPlayerStart:=class(creative_device):
#====================VARIABLE DECLARATION================
   var PlayerInfoStrucArray<public>:[]PlayerInfoStruct=array{} #PlayerIndex, PlayerTeam

    OnBegin<override>()<suspends> : void =
        TeamBalanceAsymmetric():void=

    #//==Balancing Teams Asymmetrically
    TeamBalanceAsymmetric():void=
        Print("Beginning to balance teams")
        FortTeamCollection := GetPlayspace().GetTeamCollection()
        Print("AllPlayers Length is {AllPlayers.Length}")
           
        for (TeamPlayer : AllPlayers):
            var TeamToAssign:?team = false
            set TeamToAssign = FindTeamWithLargestDifference()
            if (AssignedTeam := TeamToAssign?, FortTeamCollection.AddToTeam[TeamPlayer, AssignedTeam]):
                Print("Assigned player to a new team")
                #Find the player index and store it in the struc
                for(PlayerIndex -> PlayerType : AllPlayers): # Do for loop For all the Player
                    if(PlayerTemp :player = AllPlayers[PlayerIndex]):
                        PlayerInfoStructTemp:=PlayerInfoStruct{playerIndex:=PlayerIndex, playerTeam:=TeamToAssign}

```

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [August 13, 2023, 4:34am UTC](https://forums.unrealengine.com/t/array-of-tuple-or-array-of-struct/1228684/3 "2023-08-13T04:34:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
