How do I use families on "Create objects (by name)" right away?

0 favourites
  • 13 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello everyone!

    I have a family with 6 3D objects, each with a different name for their corresponding style: light_3d_listing, dark_3d_listing, neon_3d_listing, etc.

    I create those objects with the "Create object (by name)" action with a "style" variable: so style&"_3d_listing".

    The logic is that if I want to change the opacity, z-elevation, and size of these objects in the end, I could use the family they're all a part of! Unfortunately, it doesn't work.

    It seems that I have to add either a "Wait 0.01s" for it to "refresh the list?" or, if I want to keep it on the same tick, I need to add each transformation, for each of the 6 styles, all as a giant block of 24 actions (6x4).

    Why can't I use their family to action on whatever got created just before?

    Am I missing something?

  • Hi. I don't know the optimal method, but I'll tell you how I did it.

    For an object, I created the object by name.

    System: Create object "Sprite"

    For the family, I used a trigger event to check if the family object was created.

    + Family1: On created

  • That's another way indeed thanks for that! The issue is that it is still not in the "list" of actions where you can have local variables you need to use; this becomes external.

    If I create 1 of the 6 and want whichever of the 6 created to have an opacity of 0 without any timers, delays or other external events, I need to add an opacity 0 action for all of them in a stack. I can't use the family, and i don't why since that's the whole point of families.

  • You can add a sub-event immediately after "Create by name" and use "System pick last created family" condition. There you will be able to change the properties of the created instance.

  • You can add a sub-event immediately after "Create by name" and use "System pick last created family" condition. There you will be able to change the properties of the created instance.

    Ahhh that indeed worked! Many thanks :) I knew I missed something and that adding 0.01s delays here and there wasn't a practical solution. So I suppose that doing a Pick All with the family would "refresh" the list instantly to target all of them too? We'll test that in our code tonight.

  • Just tested it. System > Pick last created > Family works fantastic for the last created by name object inside of that family!

    However, System > Pick all > Family, doesn't work to apply something to all objects of the family; we still need to add a Wait for all of them to be selected. Any ideas about this?

    Thanks dop2000!

  • That's how Construct works - you have to wait until the end of the tick to pick newly created instances. Exceptions are: On Created trigger, Pick Last Created, Pick by UID

  • You can pick newly created instances sooner than just the end of a tick. The next top level event is enough.

  • Is it only for Create object with name? I do have many projects where I create many objects and then refer to the family to apply actions/changes to all of them, all on the same tick.

    And if I need to wait for the end of a tick, is there a Wait for a tick, instead of Wait for 0.01s as I do now (one frame for 60fps being 0.0166666667s). Is the cleaner solution to use dt?

  • It's for any created instances - create by type, name, spawn.

    You can use "Wait 0" to wait to the end of the tick.

    You can pick newly created instances sooner than just the end of a tick. The next top level event is enough.

    Somehow this rarely works for me.. Logically speaking, a function is another top-level event, right? And yet if you call it after "create" action, it doesn't know about the newly created instance. I guess the first event should finish for the new instance to be available in other events, but this is not how I prefer to build my code.

  • Maybe another way to look at it is the new objects are added to the instance list as the last step of a top level event. Functions are run in place so their new objects aren't added till the end of the caller top level event.

    It's the single most annoying quirk of the picking system, it's hard to explain, and hard to understand, but hard to not run into. With most of the events I write I do my best to work around having to deal with it.

    Anyways, I was merely pointing out it's possible to pick new objects sooner than the end of the tick if needed. It's just another tool, but if you have a different approach that's good too.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I might be lost with the terminology, but what do you mean by "top level event"?

  • An event that isn’t a sub event of anything.

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