Wallpaper Engine

Wallpaper Engine

Not enough ratings
Layer parenting - Guide
By Gariam
Guide with everything you need to know to use my Layer parenting script for Wallpaper Engine.
2
   
Award
Favorite
Favorited
Unfavorite
Introduction
With this script you can tie certain aspects of a layer to a number of other layers and have them behave the same way or similar, these aspects are the main properties of layers (visibility, origin, angles, scale, color and opacity), unfortunately it's not possible to do the same for effects.
The script supports every layer that has these properties, including particle systems, 3d models and lights.

It's possible to add some layer type specific properties, such as particle lifetime for particle systems, but with the way script properties are currently handled they would still be visible even if the script is not used on that specific type of layer, thus making it even more confusing and space wasting than it currently is. This is why i'm not planning on adding them anytime soon.

To use this you have to apply the script to any property of the layer you want to be the parent, once this is done you'll get eight script properties, seven text inputs for the actual parenting of properties and one checkbox to deactivate the script without having to delete it and losing all eventual configuration you've set.

Now, to actually create a child layer you have to write it's name (it's case sensitive) in the textbox of the script property corresponding the property you want to bind, some properties only require this, others also requires other parameters to specify how the child layer have to react to changes in the parent layer. These parameters must be separated by a comma ",".
To add other children you just have to repeat the same procedure, making sure to do it in a new line if it's the same property.


It's possible to temporarily deactivate the parenting of a property for a single layer without having to delete the line entirely thus losing it's configuration, it can be useful for testing purpose. To do this place a "-" at the start of the line before the name of the layer, this way that specific line will be ignored.
Visibility, color and opacity
Visibility and opacity require the name of the child plus one additional parameter to specify the mode. This parameter is an integer for visibility and opacity, i call it "Mode indicator", visibilty accepts 1, 0 and -1 while opacity only accepts 1 and -1, for color instead it's a boolean value (true/false) and i call it "Overwrite saturation and brightness".


Values for VISIBILITY are as follows (Mode indicator):
  • 1: direct visibilty. If parent is visible, child is also visible.
  • -1: inverse visibilty. If parent is visible, child is not visible.
  • 0: status change. If parent visibility changes, child visibility also changes, regardless of what the actual values are. ex. Parent false => true, child false => true but also child true => false.

Values for COLOR are as follows (Overwrite saturation and brightness):
  • true: applies the saturation and brightness values of the parent to the child.
  • false: keeps the saturation and brightness values of the child.

Values for OPACITY are as follows (Mode indicator):
  • 1: direct opacity. If parent goes from 1 to 0, child also goes from 1 to 0.
  • -1: inverse opacity. If parent goes from 1 to 0, child goes from 0 to 1.

Color binds the offset in color between parent and child based on the hue scale.
The hue scale goes from 0 to 360 and represent the whole rainbow with red at both ends, now if, for example, you apply this when the parent has a color of 30 while the child is 150, what this script keeps the same is the 120 of difference so if you were to apply a rainbow script to the parent, the child will also cicle through every color but shifted forward with that 120 of difference.
If you want them to be the same color you have to manually set them in the editor.

As of the time i've written this guide there's no such a thing as visibility for 3d models and no way to access their opacity and color through script, so whenever a 3d model is involded visibility, opacity and color won't work.
Lights also don't have opacity, so it won't work either.
Origin, angles, rotation and scale
What is described here is only the basic configuration of these properties, a wider customization is possible through the use of the "Axis configuration" parameter. You'll find a more in depth explanation about this in the next section of this guide.
  • Origin
    Origin binds the relative position of the child layer to the parent layer, meaning every movement made by the parent will also be done by the child. This does not make the origin of the child the same of the parent.
    This property accepts one or three parameters (not two), the name of the child layer, the axis configuration, and the indicator to bind the origin or not.
    If origin is not used while rotation is used, the child will still rotate around the parent but what doesn't change is the starting position, so if you were to move the parent under these condition the radius of the rotation will change to match the distance between parent and the staring position.
    An offset can be applied to the origin through the "Axis configuration" parameter, but if you use this you also have to specify a third boolean parameter to indicate if you want to bind the origin or just apply the offset.

    Puppet warp's bone as parent
    Only for the origin property you can also specify a single bone of the parent layer's puppet warp to use as parent, it's useful to have the child layer follow the movements of the puppet warp animation. To do this you have to specify the name (case sensitive) or index of the bone enclosed in brackets before the name of the child layer, like in the following examples:


  • Angles
    Angles, as the name suggests, binds the angles property of the two layers, so the inclination. This doesn't make the two equal but keeps the same offset between them; For example if you bind a child that is 30° more tilted then the parent, if the parent were to rotate the child would also rotate to keep that 30° of difference.
    This property accepts one or two parameters, The name of the child layer and the axis configuration. The second parameter can be omitted, the script will interpret it as you don't want to change it.

  • Rotation
    Rotation binds the relative position of the child compared to the parent, meaning that if you were to apply a rotation to the parent, the child will rotate around it to stay in the same relative position.
    This property accepts the same parameters as angles, and the second one can be omitted as well.

  • Scale
    Scale binds the size and/or the distance between parent and children. Just like angles, this property does not make the two layer of the sime size but keeps the same percentage difference in size between them, the distance instead will be widened or shortened for the same percentage value.
    This property needs three or four parameters, first the name of the child layer, then two boolean parameters (true/false) that are respectively "Scale size" and "Scale distance" (their purpouse is self explanatory), the fourth is the axis configuration, as for the previous properties this parameter can be omitted.
Axis configuration
The "axis configuration" parameter is the last one you have to write (except for origin), it's comprised of three values, one for each axis of space, it's usage is to choose which axis of the child layer is to be bound to which axis of the parent layer. The sintax is composed by three possible letters X, Y and Z (not case sensitive), exactly three of these letters must appear but they don't necessarily need to be different, by this i mean that you can put three X if you want, the first represent the X axis of the child layer, the second and third represent respectively the Y axis and the Z axis. Lastly, these letters must be separated by a space.

As i've already explained before, this parameter can be omitted, if you do that the script will interpret it the same as in the example above, because with this writing the parameter does nothing.

Now, take angles for example, if you have a rotation on the Z axis of the parent layer you can choose to apply that rotation to the X axis of the child layer instead, or even all three axis at the same time.

In this example, the rotation happening on the Z axis of the parent layer will happen on the Z axis and X axis of Child1, while for Child2 it will only happen on the Y axis instead.

Speed and direction
It's also possible to change the speed (or amount) and direction the child has to vary in relation to the parent for every axis by using a multiplier value.
This value can be any number and must be placed before the corresponding axis.

In this example, for Child1 the rotation on the Z axis will be twice as fast as the parent layer while the X axis will be half as fast. For Child2 the rotation in the Y axis will be twice as fast as the Z axis of the parent layer but reversed.

Origin
The usage method for the origin property is slightly different, for starters not all three values are necessary (you can use only one if you want) then the numbers must be placed after the letter instead of before preceded by a sign.
This is because for origin it's used to specify the offset so not necessarily every axis must have an offset and this offset is specified in pixels.
The number must be placed after the letter with a "+" or "-" between the two to indicated the direction you want the offset to go on that particular axis (absolutely no spaces, they are used to differentiate the three values).

In this example, the origin of Child1 will be moved 400 pixels to the right and 600 pixels downwards, while Child2's origin will only be moved 1200 pixels upwards.
Additionally, Child1 will have it's origin bound to the parent while Child2 won't.
Error messages and logs
The script uses the editor console to display logs and errors, you can recognise them by their color, respectively orange and red.
Logs are simple messages to display what the script is doing. Errors, on the other end, halt the execution of the script because something is not right.

When error messages appear means that a mistake as been made while setting up the configuration in the textboxes.
Do not worry because these errors also indicate where the mistake is and give a brief explanation of what is wrong, this way it's a lot easier to fix them.
If you still can't figure out how to fix them, consult this guide, it's here for this after all.

If you find logs to be annoying you can disable them by changing a value directly in the script.
At line 20, there's a constant named "logs", change it's value from "true" to "false".
1 Comments
Shadowhawksam 31 Jan, 2023 @ 2:10pm 
Thank you so much, I love making backgrounds based off of games, and this will be a really big help.:luv: