I’m following a old guide/tutorial for Unity3D (in which it still believes the scripting program used is UniSciTE). While old, I’ve been following along well enough to understand the content and place my foot in the door for Unity.
In any case, I’ve come to a brick wall. I’m able to climb the wall, but I’m doing so blindly.
The book as just introduced me to Scripts and basic parenting (I say basic because the book does not explain the actual feature until later into the book). We’ve just passed the bases of learning basic transformation tools. It explains the way the engine reads the script and why two transformation functions cannot be used in one script at the same time. So it has me create an empty (which I name Cube Parent) and attach a script (one used for moving) to it, while the script for rotating is attached to the actual object (which in this case is a cube simply named “Cube”).
The code for the moving is as follows:
#pragma strict
function Start () {
}
function Update () {
//transform.Rotate(0,50 *Time.deltaTime,0);
transform.Translate(0,2 *Time.deltaTime,0);
}
The code for the rotate is similar, with the translate commented out and the rotate not.
Now this works, I run it, the cube increases and spins. However, this is where I’m lost. How does the empty object and the cube suddenly become grouped without me ever doing so? I thought maybe it was the way he named the empty object (Cube “Parent”) which makes the game automatically link the two. So trying this, I create a sphere and a “Sphere Parent”. I attach the two scripts the same way and the sphere moves. So I figure I had it right. Deciding to try one more thing, I delete the pair, re-create them to avoid errors, then attach the move script to the parent. If they’re grouped, then the sphere should move without the script attached to itself. The sphere does nothing.
So here I am, confused like a bat out of hell, not understanding why what he did, did what it did.
Any and all help would be appreciated!