There are similarities but also some important differences between the grouping and attaching feature in CoSpaces. So how to know what to choose? But before I’ll explain, here again how to do it in the first place.
To create a group select the objects and click the group option or press the g
key.
To attach one object to another, select the attach feature, choose a slot on the other object and adjust as needed.
So what is the difference?
Orientation
When grouping two objects, an enclosing group object will be created. All objects are child elements of this object.
Now imagine that we want to move this group forward using Blockly. But what is forward if, for example, we set the man to look in one direction and the dog looks in the other direction? We don’t really know until we try it out, and sometimes the group’s “forward” doesn’t make much sense.
On the other hand, when we attach one object to another we are going to create a parent-child relationship between them.
The dog is now a child element of the man and when the man is moving forward the dog will follow along, no matter what direction the dog is looking at.
Rotation
Have a look at this group hirarchy and Blockly code.
Now we run the script.
The blue bottom block and the green top block are both child elements of the group object and they’re rotating independently (in this case they’re both rotating 360° clockwise).
What would happen if we attach the green block to the blue one instead?
Now because the green block is a child element of the blue one, it will take its rotation into account. The rotation is additive.
Animation
Animated objects are a big reason to use the attach feature. The slots which objects are attached to take the animations of the parent object into account. Have a look.
This can’t be done (or would be quite complicated) when these objects are in a group instead.
Conclusion
So what you should use? It depends on what you want to achieve. There is no better or worse method, but this small tutorial should help you to have a better understanding of the differences.