logo 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
    337
    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.
    • D
      Deeeds @Aidan_Fire
      last edited by

      @Aidan-Oxley

      Yes, I understand what you're saying about finishing something first, then distributing it. But that's not always possible because... for example, each of these 21 objects interacts with several others. Without experimentation within the full context of their relationships it's not possible to isolate one and determine the ideal. And please, given the fact I'm not a complete idiot, assume I've already done as much of that predesign as is possible without the context of others in the game world to determine the ideal interactions and player experience.


      with words:

      I'm assuming its one of the loops combined with arrays that will make this possible, as this is how it would be done in any other environment.

      The thing that I'm missing is understanding how to group objects for consideration by the conditional that's determining who to put where, that somehow individualises each instance and doesn't make the mistake of applying two different positions to one object.

      I'm assuming tags would be the way to do this differentiating, but can't see how to serialise/individualise the instances in a way the loop knows about.

      So, let's say:

      Tags are parent and child.

      The Arrays will need to be two, one for X values and one for Y values because there's no vector type and/or vector storage available (that I know of) within hyperPad.

      So we have two arrays, one is 21 X values, the other is 21 Y values.

      Each of these must be a pair, by virtue of sharing the same index in their respective arrays.

      In this way we're making an imaginary two dimensional Array [X, Y]

      We can't use a dictionary because some of the X values are the same, and some of the Y values are the same, so there's no unique key available, nor are they knowable without making another Array of those key values.

      So the loop starts by needing to know the length of one of the Arrays, probably X.

      Having found that, the loop then needs to be this length, and for each index value it needs to seek a unique object and apply the setting of X and Y values from the current index in each array to the position values of this object. Then release this object and grab the next one and the next two "pairs" of X and Y from the array.

      Having done this for the parent tag, the next loop doesn't need the arrays of positions, it can seek out positions within each of the parents and apply it to the children, making relative relationships in position during this iteration over the loop.

      This is a pretty common thing to do in all sorts of environments, but probably somewhat of a spaghetti mess in this environment.

      Jack8680J 1 Reply Last reply Reply Quote 0
      • 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