Scirra / Construct-feature-requests

A place to submit feature requests and suggestions for Construct.
https://www.construct.net
8 stars 1 forks source link

[SDK v2.0] Add scene graph options getter to IWorldInstance #273

Open LuanHimmlisch opened 1 month ago

LuanHimmlisch commented 1 month ago

Reviewed guidelines

Checked for duplicate suggestions

Summary

Being able to get the options that a IWorldInstance is configured in a parent: image

It should return a similar object as the one passed when adding a child: image

Possible workarounds or alternatives

There's no way to know the configuration of a child.

Proposed solution

Add a getParentOpts() or similar to get the options:

const opts = mychild.getParentOpts(parent);

if(opts.transformY){
    // ...
}

Also, a QOL feature would be to automatically attach this object when iterating over children with allChildren. Maybe on an extra hierarchyOpts key.

for(const child of parent.allChildren()){
    console.log(child.hierarchyOpts);
}

Why is this idea important?

This would allow to automatically create hierarchies on the fly perfeclty.

The current case, is for syncing an entire hierarchy tree using the Multiplayer Sync.

You could sync just one object, and have the host send the objectType names + hierarchy options. And have the client recreate the hierarchy perfectly with the same options, with minimal code.

Additional remarks

No response

LuanHimmlisch commented 1 month ago

To illustrate my example further, here's the code of how would you do it currently

image

As you can see, the opts key is being filled by suppositions based on the equality of the values with its parent, however this may be correct or incorrect, as a child could sync any value relative to a parent, thus not being the same value.

Having a getter to get these options would make it possible to recreate hierarchies on the fly.