Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

parent and child entity active states bug?

in Bugs Posts: 386
@John changing the from false to true will set all the This does not seem to me to be the desired behaviour? I think the visibility of a child should be the product of the parent and the child active states- the child active state should not be modified.


  • SimeonSimeon Admin Mod
    Posts: 4,958

    That does seem like a bug that's easily fixed, I'll see what @John thinks

  • JohnJohn Admin Mod
    Posts: 573

    Unity has a similar thing, active vs activeSelf vs activeInHierarchy. I'll see if I can do something similar.

  • dave1707dave1707 Mod
    edited December 2018 Posts: 7,606

    @piinthesky @Simeon @John I thought I’d try playing with the parent children Craft variables. I can control each of the children (red or blue ball) by the children parameter. I can control both the red and blue ball by the parent parameter, but only if the child parameter is on. If both children are on, I can turn them both off or on with the parent parameter. If one is on, I can turn it off, but I can’t turn the one that was originally off back on with the parent parameter. I think it works the way it’s supposed to. I don’t know if this is what’s mentioned in the top post or not.

    PS. After playing with this more, I think I see what’s happening with the original post. If I comment out the 2 child parameters and comment out the code in the function active() that controls the 2 children and add code to turn the 2 children active to false in the function createObjects(), then turning the parent parameter on and off will also turn the 2 children on and off even though they were off to start. I think that also works correct. If I don’t control the children individually, then the parent should.

    function setup()
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        scene = craft.scene()
        parent=scene:entity(), vec3(0,0,0), 50, 0, 200)
    function createObjects()    
        sphere1.model = craft.model.icosphere(4,2)
        sphere1.material = craft.material("Materials:Specular")
        sphere2.model = craft.model.icosphere(4,2)
        sphere2.material = craft.material("Materials:Specular")
    function draw()
    function active()
        if parentActive then
        if redActive then
        if blueActive then
    function update(dt)
  • JohnJohn Admin Mod
    Posts: 573

    @dave1707 I think what @piinthesky is looking for is for the active status of a child to be preserved so that if you had a fairly complex hierarchy and disabled the root, the children that were previously disabled would remain so when the root was enabled again.

    In your example it looks like you are manually keeping track of active status for each thing and refreshing them in the correct order each time one of them changes. It works, but it's more complicated and duplicates state.

  • dave1707dave1707 Mod
    edited December 2018 Posts: 7,606

    @John Now that you explain it that way, I see your point. If I control them, they work the way I want them to. If I don’t, then they don’t work the same way.

    PS. I never tried the parent/child code before this so I didn’t know how they were supposed to work. I thought I had to control them individually.

  • @dave1707 @John, sorry if i did not explain it very well. @john explained it better. I often use a parent as a master switch to control whether all its children are visible or not. The active state of the children themselves can be quite complex and for me should not be modified by the parent state.

    @john, it seems the ar.pause/ works properly now, did you fix it?
  • dave1707dave1707 Mod
    Posts: 7,606

    @piinthesky You probably explained it well enough, I just didn’t know enough about how the parent/child process was supposed to work. Like I said above, I never tried using them before so you got me to learn something new which is always good.

  • what must i include as dependencies to try this? and will it work on 2.6.1? thanks!

  • sorted, thanks

  • SimeonSimeon Admin Mod
    Posts: 4,958

    @RonJeffries the next version no longer requires Craft as an explicit dependency so the option will be removed. All projects will just include it implicitly.

  • yay. now that i understand. :)

  • Posts: 386

    @john did you get a chance think anymore about the parent/child active issue? It would simplify my life a lot if the child state was not modified by the parent state and its visibility was the product of the states in its hierarchy.

Sign In or Register to comment.