How do I Edit change Family's property when the child is made?

0 favourites
  • 5 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hello there,

    I'm having some problem with a process that I'm trying to achieve.

    I have a sprite, and a family that contains 100 tiled backgrounds.

    In each sprite in the layout, a function is started. The function, would create a tiled background by name (taken from the Sprite variable) and then, when the object is create, I would need to access the variable or property in its family.

    The problem comes to the last part. I'm able to spawn the different tiled background depending on the name, however I'm not able to access the family property. So, let's say that I want to heredity the width, height and angle of the sprite, I can't do it if I select the family. I would avoid to make 100 different events to select the specific tiled background to edit based on the name.

    I did several tests, and it seems that I'm not able to access the family variables/properties because the object made is the tiled background. However, I'm not able to create the family and then choose which child create.

    I have been thinking about different solution, such as using the scripting to change the properties I need to change (width, height and angle), however in future I might need to change more advance things.

    Here the file as an example: https://feribi.com/tiledBackgrounds.c3p , as you can see in the debug mode, if I try to set the id2 (in the family) it wont work.

    Thank you!

  • After you create the tiled background use "Pick Last Created tbFamily." Then you'll be able to talk about the tbg in terms of it's family

  • After you create the tiled background use "Pick Last Created tbFamily." Then you'll be able to talk about the tbg in terms of it's family

    Thank you, that worked good.

    Is there any other way to select the child into the family as I explained?

    Thank you!

  • > After you create the tiled background use "Pick Last Created tbFamily." Then you'll be able to talk about the tbg in terms of it's family

    Thank you, that worked good.

    Is there any other way to select the child into the family as I explained?

    Thank you!

    I don't think there's any other way. Doesn't the solution I gave you work?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • when you create an object, the process doesn't complete until the next top level event.

    your "on start of layout" event loops through each spawner, creating a new tiledbackground object, but those objects wont be ready until event 4 is completely finished.

    so, in your code, event 3 was trying to pick the family object by its id2 variable, but that will fail because the new object is not ready yet. Only the pick last created, or pick by uid will work at that point.

    putting a wait 0 seconds as an action will defer other actions under that until the end of the current tick, by which time the new objects will be ready, but people quite often create other problems if they don't use that properly.

    you were using iid which is not as reliable as uid. iid for an object will change if you destroy an earlier instance of that object. the uid will not change, and is the same for the original object and the same object under the family name.

    so, picking by the variable would have worked fine - but not until the after the object is fully created.

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