Position 21 Objects with Arrays and Loops: HOW?
-
@Deeeds you can use an attribute to give an object in a tag a unique ID, then use a 'for each' loop with the tag selected. It will loop through each object in the tag and pass the object down to any other behaviours using the tag under the loop. So you could get an array value based on the order they spawned in, or whatever other method they use to get an ID.
If you want to spawn them at a specific point though, you can use the spawn on area behaviour to spawn them, and set both corners of the area to the point you want to spawn them at. You could do this from x and y arrays using a regular loop with the array length as number of loops, and get array value with the index of the loop.
It would be nice if we could select spawned objects without loops though.
-
@Jack8680 If I'm making the objects in the Scene Editor, and they all have unique names because of this, do I need the attribute?
-
@Jack8680 And completely agree, named access to ANY and all objects would be a huge benefit. Massive. World changing.
-
@Deeeds it depends what exactly you're looking to do. If it doesn't matter which object moves to which point, you could just use the for each loop and use the index to choose a position to move them to, but if you want a specific object to move to a specific point you'd need to use an attribute.
-
@Jack8680 EDIT: Stalled browser copied in a sentence from another post: DELETED:
So the attribute could be an integer, and 0 through to 20 (21 objects) by which to refer to them in the loop? Is this sort of sorting possible in hyperPad?
-
@Jack8680 I'm cursed by the 120 second timer before I can post follow ups.
-
@Deeeds you don't need an id to loop through the objects, the for each loop automatically loops through all objects in the tag and sends that specific object to any behaviours below that refer to that tag. For example:
For each tagobject: Get ID of tagobject MoveX = xArray[ID] MoveY = yArray[ID] Move tagobject to (MoveX,MoveY)
-
Or instead of ID you could get rid of the get attribute and use the loop index to get the position, if it's not a specific object that needs moving.
-
@Jack8680 Sorry for these stupid questions:
Is "Get ID" a use of Get Attribute?
Where ID is the type of attribute and the ID's value could be string or Int?
-
@Deeeds yeah it's a get attribute. You could use strings as ID too by using a dictionary rather than an array. ID is just the attribute name.