Don't use "Pick Nth child" condition, it's broken

0 favourites
  • 8 posts
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • Spent a lot of time yesterday trying to figure out why my code doesn't work.

    Apparently this is leg number 6.

    Project file:

    dropbox.com/scl/fi/cqg2qnumsu1muwkzbl7fr/PickNthBug2.c3p

    Tagged:

  • I am only going by screenshot, but, is it struggling to pick nth if you're picking higher ID than the picked count?

    I am curious what it does if you have 2 legs and you pick 6th, does it pick highest IID or does it loop around?

  • It's not leg number 6, it's the child at index 6, which is of the leg object type.

    If that counted as leg 1, and there was also an arm 1, then the array of child instances would have two different instances at the same index, which doesn't make sense. Hierarchies have a single array of all children for each parent, not a separate array of children per child object type.

  • Seems like the index is tied to all children not only the children of that objectType. There also doesn't seem to be a way to know which one is which aside from trying each one.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley I understand you reasoning. But for us, end users, this feels like a 100% bug.

    There are only 2 leg instances, and I should be able to pick them by index 0 and 1. If they have random indices and no way to know them other than loop through the entire hierarchy - then this condition is useless. It's much easier to use a combination of "Pick children" and "System pick Nth".

  • I agree, The "Nth" it should be a relative number, not an absolute number.

    We should select the Nth child object of the same type relative to the parent object, rather than a specific one in the entire hierarchical family tree.

    In this (example.c3p), only the first event works, the others do not work as expected.

    I know that the yellow box has 3 blue box child object, so I just need to select the number via 0, 1, 2. Let's go a step. if i want to continue selecting the last red box of this blue, what should I do?

    If I have to save this index manually, It's much easier to use another system comparison condition.

  • I've added an extra parameter for the next release to "Pick Nth child" so you can choose whether the index is relative to all children (as it works now), or filtered to only the chosen object type (so it works like you want it to here). But I'd note this filtered mode actually works inconsistently to the other existing features - for example the 'Compare child count' condition and 'ChildCount' expression work with the list of all children. There is still no way to compare the child count of just one type of child, nor does there seem to be any good way to design an expression that returns the child count of just one given object type, as the current design of Construct does not allow an object type to be passed to an expression. So while the next beta allows you can pick from a filtered list of children of a given object type, there is no way to identify how many children there are of that type, nor is there any obvious way to design such a feature at the moment. I suppose if you have a fixed hierarchy setup, such as every hierarchy has both two arms and two legs, then picking Nth child with filter may be good enough, but usually I'm pretty reluctant to introduce feature inconsistencies like this - eventually someone else turns up and says "this mode is inconsistent/incomplete, it shouldn't be designed like that..." and we have a similar discussion like this again.

  • Thanks, Ashley.

    My frustration was from the fact that this condition was disguised as "System pick Nth instance". And it was working correctly in my code for a while (or so I thought). But then it broke one day for no apparent reason.

    Maybe it should've been called something like "Compare object type at Nth index in hierarchy".

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)