3D - Using Your UFO as a Model (Difficulty: 2)
CreatiCode last edited by info-creaticode
- Parent-children relationship
- Naming objects
- Speeds of objects
- Export object as a GLB file
- Community models
In an earlier tutorial, you learned how to build a UFO. In this tutorial, you will learn how to control it to fly around, and also how to allow others to use your UFO model as well.
Save this project as a copy, and give it a new name, such as “Flying UFO”. It is often a good idea to make copies of your projects, so that if you delete any block or sprite by accident, you can recover it from the original project.
Currently, our UFO has 3 components. To make them act like one, we need to link them up, using the parent-children relationship.
To do that, we first need to give each component a name, such as “p” for the main body, and “c1” and “c2” for the other 2 components:
Now we can set “p” as the parent of the 2 child components.
Note that after this step, you still don’t see any difference when you run the project, but your UFO can now be treated as one object instead of 3.
For a simple test, let’s make the UFO fly and spin. To control the entire UFO, we need to select the parent object “p” as the sprite object. When we set the rotation and rising speeds of “p”, all its children will do so as well.
Suppose you love your UFO model so much that you want to use this UFO in other projects, and also allow others to use it. To do that, we need to export the UFO object as a GLB file.
You only need to run this one block (place it anywhere in the code editor):
The GLB model file may sometimes get really large. It will take longer to load large files, so people in general prefer smaller model files.
To make the file smaller, we can reduce the number of “sides” of each sphere from 64 to 32 to 16. The visual quality would not change too much, but the file size will be much smaller.
Now we have the GLB file, we can upload it as a new “community model”, so that you and any other user on the CreatiCode platform can use it for free.
To do that, go to the “My Stuff” page, and click the “3D Models” category. Click “Share a New Model”, then select the GLB file you want to upload.
Note that depending on the file size, sometimes it might take a few minutes to upload a model file.
To test out your new model, you can create a new project with an empty scene, then load the model using the “add community model” block:
Now you can use this UFO object the same way as how you use any other model provided in the library.
You can use this method to build and share many different types of objects, such as a house or a smiley face.
In addition, you can try to make the model file smaller by changing the geometry and material of your UFO. For example, try to change the number of sides from 64 to 32 or 16, and check if you can get a smaller file.