Your first prefab
This tutorial builds one GameObject from components, saves it as a prefab, and spawns copies of it.
1. Add an empty GameObject
Section titled “1. Add an empty GameObject”- Open your tutorial scene if it is not already loaded.
- In the Scene Hierarchy, create a new empty GameObject.
- Rename it
sphere.
New GameObjects come with a Transform. That is enough to start.
2. Add a mesh
Section titled “2. Add a mesh”- Select
spherein the Scene Hierarchy. - In the inspector, Add Component -> Mesh Filter.
- Set Kind to Sphere.
- Add Component -> Mesh Renderer so it draws.
You should see a sphere in the viewport. Move it beside your cube with the translate gizmo (W), and set Position Y so it sits on the ground.
3. Add physics
Section titled “3. Add physics”- With
spherestill selected, Add Component -> Sphere Body. - Open the body component in the inspector.
- Leave Motion on Static for now. The physics tutorial switches it to Dynamic.
4. Save it as a prefab
Section titled “4. Save it as a prefab”- With
spherestill selected, File -> Save prefab (or the Prefab section in the inspector). - Save it under the project’s
assets/prefabs/folder with a name such assphere.
The prefab is a JSON document under assets/prefabs/. Mesh, renderer, and physics travel with it.
5. Spawn a copy
Section titled “5. Spawn a copy”- Open the Asset Browser (
Shift+Space) if it is closed. - Find the
sphereprefab and drag it into the viewport. - Move the new instance so it is not sitting on top of the first one.
You now have two spheres from one prefab. Each instance in the scene is its own copy. Editing one does not change the other.
6. Prefab updates
Section titled “6. Prefab updates”Prefabs do not auto-update. Saving the prefab file again does not refresh instances already in the scene. They keep what they had until you respawn them from the Asset Browser.
7. Save the scene
Section titled “7. Save the scene”File -> Save Scene (Ctrl+S) so the new GameObjects stay in your scene.
Continue reading
Section titled “Continue reading”Previous: Your first scene: save a small .scene.
Next: Add physics: a dynamic body and a push.
