Is there an explanation on the parent/child code anywhere? I’ve been teaching myself to code. I can’t find examples that explain what it is and how it works. Is it different from grouping?
Grouping and parenting different items together are similar functionalities, but come with their own unique behavior. Let’s have a look!
Grouping items together is done by selecting several items at once (via shift+click or marque selection) and pressing Group (keyboard shortcut
When should I use grouped items?
- Grouped items are useful when you want to create reusable building blocks for an environment. Don’t want to repeat creating those chairs for your 3D Cafe? Group the items together and copy the group
- Code that can be run on groups will also be applied on all items inside of the group! This is a time saver and gives you more control over everything happening inside of a group
Parent-child hierarchies connect the position of an item (the child) to another item (the parent). Chances are you already made parent-child hierarchies with the Attach-feature.
The Attach-feature parents an item to another item via a slot, thus making it the child of this parent.
In the example above you see that…
girlis the parent for the
cowboy hatand the
cowboy hatis the parent for the
If you parent items via slots, the children will also move with the slots when they’re animated.
Here the cowboy hat moves with the head-slot of the child, the mouse moves with the top-slot of the hat, the gift moves with the hand-slot of the child
Alternatively, items can be parented to another item without slots, too. This will move the child-item with the parent, but not with its animations
Here the dog is parented without a slot. It moves with the parent, but not with animations
When should I parent items?
- If you want items to move along with animations (attaching via slot)
- If you want to make the movement of one item dependent on the movement of another (attaching without slot)
Parent-child hierarchies are incredibly flexible and help you connect items to slots and the position & rotation of another item.
Feel free to remix this space to learn how you can use CoBlocks to parent & unparent items!
Hope this helped breaking down the differences between grouping and parenting
Thank you so much for this! It reallys helps me understand it better.
I was explaining to my kids in class yesterday that I didn’t always know the answers, but I could reach out to everyone at CoSpaces and they always got back to me with answers, My students thought this was the coolest thing ever!! Thanks!!