hyperPad hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Position 21 Objects with Arrays and Loops: HOW?

    Scheduled Pinned Locked Moved
    Help and Support
    3
    13
    382
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jack8680J
      Jack8680 @Deeeds
      last edited by

      @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.

      D 2 Replies Last reply Reply Quote 1
      • D
        Deeeds @Jack8680
        last edited by

        @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?

        Jack8680J 1 Reply Last reply Reply Quote 0
        • D
          Deeeds @Jack8680
          last edited by

          @Jack8680 And completely agree, named access to ANY and all objects would be a huge benefit. Massive. World changing.

          1 Reply Last reply Reply Quote 0
          • Jack8680J
            Jack8680 @Deeeds
            last edited by

            @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.

            D 2 Replies Last reply Reply Quote 0
            • D
              Deeeds @Jack8680
              last edited by Deeeds

              @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?

              Jack8680J 1 Reply Last reply Reply Quote 0
              • D
                Deeeds @Jack8680
                last edited by

                @Jack8680 I'm cursed by the 120 second timer before I can post follow ups.

                1 Reply Last reply Reply Quote 0
                • Jack8680J
                  Jack8680 @Deeeds
                  last edited by

                  @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)
                  
                  Jack8680J 1 Reply Last reply Reply Quote 0
                  • Jack8680J
                    Jack8680 @Jack8680
                    last edited by Jack8680

                    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.

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      Deeeds @Jack8680
                      last edited by

                      @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?

                      Jack8680J 1 Reply Last reply Reply Quote 0
                      • Jack8680J
                        Jack8680 @Deeeds
                        last edited by Jack8680

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post