Ok so CAT basically follows the paradigm of a base transform with additional transforms existing as layers. This is synonymous with its ‘setup’ layer and ‘animation layers’ - the only controllers that get keyed, saved as animation etc are the ones treated as layers.
This ‘treatment’ is by allowing a float controller to have internally multiple sub-controllers i.e the animation layer, relative/absolute layer.
The CreateLayerFloat function of a hub node creates the controller on itself, and then gets instanced onto a target float controller. Here’s how:
(
-- first off lets build a CATParent & add a hub
[B]local[/B] p0, root, null, layerController
p0 = CATParent()
null = point()
root = p0.AddHub()
root = p0.RootHub
-- now we create the float controller and instance it
layerController = root.CreateLayerFloat()
layerControllerr.setupVal = null.pos.controller[1].controller.value
null.pos.controller[1].controller = layerController
)
So the createLayerFloat (as the name implies) only allows it to be instanced onto float controllers.
Now currently this is instanced onto the base controllers of the null. But what if we need to add some custom scripting or a base transform that doesn’t need to exist with in the layers paradigm i.e. what if we want to give the null a base constraint e.g. a position_constraint:
(
[B]local[/B] p0, root, null, layerController
p0 = CATParent()
null = point()
root = p0.controller.addHub()
root = p0.rootHub
null.pos.controller = position_list()
null.pos.controller[1].controller = position_constraint()
null.pos.controller[1].controller.appendTarget root.node 100
null.pos.controller.available.controller = position_xyz()
null.pos.controller.setActive 2
layerController = root.CreateLayerFloat()
layerController.setupVal = null.pos.controller[2][1].controller.value
null.pos.controller[2][1].controller = layerController
)
Now this null follows the root hub, but its own x position controller inherits the layers system.
Now sometimes you’ll want to get the value of layer on the float controller of the null, we can call this:
null.pos.controller[2][1].controller[currentlySelectedLayer]
And to get the current selected layer we have to get the CATParent - something sadly we cant pull from the layerFloatController (unless we embed it into an attribute or something):
root.CATParent.SelectedLayer
-- or
p0.SelectedLayer
You’ll need to do this for variables that you have to pull out of custom attributes for example. And you’ll have to check if the animation mode is on etc…