Get Position Set to a Tag, What's happening?

  • When doing a For Each loop, over a tag, and getting their positions, the results for first and last were not the same as that of a solo effort at Getting a position of the Tag.

    It appears to have chosen the second object in the list of tagged objects as the For Each loops sees them.

  • @Deeeds Ohh this is cool. For some reason I never thought of that, but I think the for each loop would act on each object in the tag individually. I think when you get position of the whole tag in one go (without a for each loop) it just gets their average position (basically the middle of them all). I’d test this, but I’m too lazy.

  • @Aidan-Oxley No, it's getting the position of a specific member of the tag group. I've confirmed it, it's the second one.

  • @Deeeds Are you sure that the position of the second one doesn’t happen to be the middle of all of them? I’m gonna go test this now I’ve stopped being lazy.

  • @Deeeds Testing done. I made 4 objects in a tag, each in the exact position of each corner of the screen. Then I added another two objects (labels), they got the position of the tag (with no conditions, so it just happens as soon as the project is run), and set themselves to whatever this Get position output, one label being x and the other y. It ended up giving me the coordinates of the exact centre of the screen, meaning it does get the average position of the group (if there are no conditions somehow relating to the tag, such as for each loop, collided etc).

  • @Aidan-Oxley using your theory, what should come out of this... x on the left, y on the right...

    100, 1
    112, 1
    124, 1

    106, 12
    118, 12
    130, 12

    112, 23
    124, 23
    136, 23

  • @Aidan-Oxley

    Given your propensity for maths...

    How do I take an incoming stream of numbers between the ranges of -20 to +20, and always output a number of 100 for values between -10 and +10, but scale that output downwards for numbers between -10 to -20, and 10 to 20?

    Here's the tricky part, without using a conditional, only math.

    I believe this is called "flooring", but I could have that wrong, as google isn't helping me.

    Nor is it my friend.

  • @Deeeds The average of those 9 values is 118, 12
    I’ll look at what you said after that in a while.

  • @Aidan-Oxley So to be absolutely clear,

    Get Position on a Tag iterates over all members of a tag.


  • @Deeeds Get Position on a tag will get the average position of ALL objects in that tag. Unless you’re using something like a for each loop running over the top of the Get Position, in that case it will get the position of each one I would expect, all in a super short time due to how loops work. You can also use Collided with tag over the top of Get Position of tag, in that case it will get the position of the object it collided with.
    But once more, if the Get Position behaviour has nothing like this above it, it will just get the average position of everything in the tag.

  • @Deeeds With what you said about your values between -20 and +20, I can’t imagine any way possible without having at least two separate conditions, one being that the value is between - and + 10, and the other condition for if that condition is not met.

  • @Deeeds Here you go have an example project:

  • @Aidan-Oxley The reason I'm asking:

    I think this is poor design.

    It is my opinion the For Loop Operating on a Tag should output three things, not two.

    As of now the loops output their Index and their Count.

    The For Each Loop should also output Each.

    So the output choices would be:

    Index, Count, Each

    Then you can, quite logically and naturally, do this:

    Get Position Each:

    Get Rotation Each:

    Set Rotation Each:

    Makes a lot more sense than repurposing Get Position Tag from a catch all and averaging to a constraint of itself to the context of a For Loop that's specifically referencing each instance it finds that meets the criteria of For Each.

    And, it's right their in the name of the operation: For EACH!

    And, further, I think this is the right preparatory move towards hyperPad having object references, prefabs (types) and instancing.

  • @Deeeds I don’t really understand what you mean. When you run a For Each Loop above a Get Position, I’m pretty sure it will get the individual position of every object in the tag one by one, not the average.

  • @Aidan-Oxley yes that’s how it works. I posted a project for him yesterday doing just that.

  • @Deeeds you can already easily do this:
    Get Position Each:

    Get Rotation Each:

    Set Rotation Each:

  • @iTap-Development @Aidan-Oxley

    Forest for the Trees.

    Trees for the Wood.

    I'm suggesting a better UI and UX that's more consistent, easier to grok and, most importantly, discoverable.

    The current system requires rote learning and is a peculiar repurposing of an iterator within an iterator that no longer iterates because it's in an iterator.

    But it's not as bad as how the If Else is created, I'll grant you that!

Log in to reply