1
0
mirror of https://github.com/godotengine/godot synced 2024-07-05 16:43:46 +00:00

Updated tutorial_instancing (markdown)

reduz 2014-03-30 18:05:20 -07:00
parent 342f3c7772
commit 438b1afc22

@ -6,15 +6,15 @@ Having a scene and throwing nodes to it might work for small projects, but as a
To recap: A scene is a collection of nodes organized as a tree, where they can have only one single node as the tree root.
<p align="center"><img src="images/tree.png"></p>
<p align="center"><img src="images/tree.png"/></p>
In Godot, a scene can be created and saved it to disk. As many scenes can be created and saved as desired.
<p align="center"><img src="images/instancingpre.png"></p>
<p align="center"><img src="images/instancingpre.png"/></p>
Afterwards, while editing an existing or a new scene, other scenes can be instanced as part of it:
<p align="center"><img src="images/instancing.png"></p>
<p align="center"><img src="images/instancing.png"/></p>
In the above picture, Scene B was added to Scene A as an instance. It may seem weird at first, but at the end of this tutorial it will make complete sense!
@ -24,24 +24,54 @@ To learn how to do instancing, let's start with downloading a [pre-made scene](m
Unzip this scene in any place of our preference. Then, add this scene to the project manager using the 'Import' option:
<p align="center"><img src="images/importproject.png"></p>
<p align="center"><img src="images/importproject.png"/></p>
Simply browse to inside the project location and open the "engine.cfg" file. The new project will appear on the list of projects. Edit the project by using the 'Edit' option.
This project contains two scenes "ball.scn" and "container.scn". The ball scene is just a ball with physics, while container scene has a nicely shaped collision, so balls can be thrown in there.
<p align="center"><img src="images/ballscene.png"></p>
<p align="center"><img src="images/contscene.png"></p>
<p align="center"><img src="images/contscene.png"/></p>
Open the container scene, then select the root node:
<p align="center"><img src="images/controot.png"></p>
<p align="center"><img src="images/controot.png"/></p>
Afterwards, push the '+' shaped button, this is the instancing button!
<p align="center"><img src="images/continst.png"></p>
<p align="center"><img src="images/continst.png"/></p>
Select the ball scene (ball.scn), the ball should appear in the origin (0,0), move it to around the center
of the scene, like this:
<p align="center"><img src="images/continstanced.png"></p>
<p align="center"><img src="images/continstanced.png"/></p>
Press Play and Voila!
<p align="center"><img src="images/playinst.png"/></p>
The instanced ball fell to the bottom of the pit.
###A Little More
There can be as many instances as desired in a scene, just try instancing more balls, or duplicating them (ctrl-D or duplicate button):
<p align="center"><img src="images/instmany.png"/></p>
Then try running the scene again:
<p align="center"><img src="images/instmanyrun.png"/></p>
Cool, huh? This is how instancing works.
###Even More!
Select one of the many copies of the balls and go to the property editor. Let's make it bounce a lot more, so look for the bounce parameter and set it to 1.0:
<p align="center"><img src="images/instedit.png"/></p>
The next it will happen is that a green "revert" button appears. When this button is present, it means we modified a property from the instanced scene to override for a specific value in this instance. Even if that property is modified in the original scene, the custom value will always overwrite it. Pressing the revert button will restore the property to the original value that came from the scene.