Parent child explained

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?

1 Like

Hi @Mary_Beth_Burns,

Grouping and parenting different items together are similar functionalities, but come with their own unique behavior. Let’s have a look!

Grouped items

Grouping items together is done by selecting several items at once (via shift+click or marque selection) and pressing Group (keyboard shortcut G).

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 :slight_smile:
  • 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…

  • The girl is the parent for the cowboy hat and the gift
  • The cowboy hat is the parent for the mouse

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 :slight_smile:

1 Like

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!! :slight_smile:

1 Like

can you use parent child to use the camera to drive objects

Hi @Jackson_Grieves,

To move items with the camera, simply parent them to the camera-item via drag and drop in the item hierarchy. Here’s how:

1 Like

This was very useful thanks! I just have one more doubt, I want to use parent-child to make another object move in sync with the camera, but only after having touched the object first. Is there any way of doing this? Thank you.

Hi @Clara_Fernandez,

Yes, it is possible. How you do this depends on what you want to happen afterwards.

In CoSpaces Edu PRO, you can use the add child block to either attach the camera to the object or the object to the camera, for example:

You can remix this CoSpace I made to demonstrate this:

Hope this helps! Let me know if you have any further questions.

Geoff @ TechLeap

Thank you for your suggestion, unfortunately, I had already tried to do this and when I clicked in the object the camera started flying off and there was nothing I could do to stop it. I found a way of solving this thanks to another comment and I already managed to do what I wanted to do, but thanks anyway!

1 Like