3D - Using Your UFO as a Model (Difficulty: 2)
-
Key Topics Covered
- Parent-children relationship
- Naming objects
- Speeds of objects
- Export object as a GLB file
- Community models
Introduction
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.
Step 1 - Make a Copy of Your UFO Project
First, go to the “My Stuff” page on the CreatiCode website, and search for the UFO project you created before. If you don’t have it yet, please complete this tutorial first.
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.
Step 2 - Name each component of the UFO
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:
Step 3 - Set up parent and children relations
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.
Step 4 - Make the UFO Fly and Spin
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.
Step 5 - Export the UFO As a Model File
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):
Step 6 - Reduce the Model File Size
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.
Step 7 - Upload and Share Your Community Model
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.
Step 8 - Use Your Community Model in a New Project
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.
Creative Ideas
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.
-