- Home /
Control the unscripted GameObject
Hai, i just want to know, can i make a GameObject via script then controlled that GameObject (such as moving or rotation)? thanks
Answer by FlowStateGames · Dec 11, 2012 at 11:49 AM
Yes, you can create a GameObject. If you store a reference (by setting the GO you created as a variable), then you have full access to that GO. You can create empty ones, and you can also pass in an argument to the constructor to create a prefab. If you do that, you will have access to all the script components (as well as all other components - rigidBody, etc) which belong to that prefab.
The docs are your friend, see here for an explanation and example. Before you ask basic questions such as this, do some searching in the manual and here.
Edit: So if you want to rotate that GameObject, you might do something like this:
void CreateObject()
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.rotation = myDesiredRotation;
}
Like I said, if you look at the link I posted, you will see a ton of examples, showing you how to create and manipulate gameObjects.
ok, i can add some gameObject "thing" like rigidbody, light, or something else. but in my question, can i rotate the Instance GO without any script attached to that GO.
Your answer

Follow this Question
Related Questions
How to move a GameObject with an animation 2 Answers
GameObject pivot vs center 1 Answer
left hand invaders moving into each other 1 Answer
Creating and Moving objects 2 Answers
Mouse drag with specific angle 1 Answer