0 Favourites

UIDs into Arrays

  • Arrays are killing me. How do I get the UIDs of 4 instances of one object into 4 slots in an array?

    I created an object, dragged 4 instances of it to the Layout. Then I created an array on the layout and get it dimensions of 4,1,1.

    On the event sheet I tried:

    Array>For Each element on the event

    Array>Set Value at Arrayname.At(loopindex) to objectname.UID on the action

    It doesn't seem to work and I can't figure out where it's messed up. Can anyone help explain this concept? Once the UIDs are in the array, I think I know how to use the array with For Each statemes.

    Thank you in advance for any help

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • put the capx it will help us to know the problem , about arrays they sets variable as x,y and they can store many value

    put a variable in the object

  • your goin about it backwards. You dont loop thru the array to assign the UIDs you loop thru the objects to assign the UIDs

    theres no loopindex for "for each" so make a local var and in the for each add 1 to it AFTER you assign the UID to the array.

    for each "object" -> Set Value At "count var" to object.UID

    Add 1 to "count var".

    Now your array will contain the UIDs. You can also dynamically size the array to the number of objects but it has to be done before you start assigning values to the array

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Fill Array with Sprites
48 2,319
Congrats2u's avatar
Congrats2u
Unread hot topic
0 Favourites
How do i use arrays?
44 6,458
HapaxHypatia's avatar
HapaxHypatia
Unread hot topic
42 32,378
Ragevortex's avatar
Ragevortex