|
Java Code - Create / Destory Object
[Back]
Code:
//Create
var object : GameObject; //This is the Variable that will let you pick what object you want it to create
Instantiate(Object, transform.position + Vector3(0, 0, 0), Quaternion.Euler(0,0,0) );
//Create a object using the var Object and set the position and Rotation
//Add Force to objectvar shoot : GameObject;
//Mouse Down
var object : GameObject = Instantiate(shoot, transform.position, transform.rotation);
object.rigidbody.AddForce(transform.forward * 100);
//end
var object : GameObject = Instantiate(object, transform.position, transform.rotation);
//This will create the object on top of the object this code is on.
(Help)
var object : GameObject = Instantiate(object, transform.position + Vector3(0, 0, 0), transform.rotation);
//This will create the object at a point by the object this code is on. The three 0 are the (X,Y,Z)
var object : GameObject = Instantiate(object, transform.position, Quaternion.Euler(-0,0,0) );
//This will create the object and set the rotation of the object. The three 0 are the (X,Y,Z)
//Destroy
Destroy(gameObject); //This will destroy the object it's on.
(Help)
Destroy(GameObject.Find("test")); //Destroy other object in the scene, test is the name of the other object.
(Help)
Destroy (gameObject, 10); //Kills the game object in 10 seconds after being created, the 10 seconds can be any time.
(Help)
var object : GameObject; //This is the Variable that will let you pick what object you want it to create
Instantiate(Object, transform.position + Vector3(0, 0, 0), Quaternion.Euler(0,0,0) );
//Create a object using the var Object and set the position and Rotation
//Add Force to objectvar shoot : GameObject;
//Mouse Down
var object : GameObject = Instantiate(shoot, transform.position, transform.rotation);
object.rigidbody.AddForce(transform.forward * 100);
//end
var object : GameObject = Instantiate(object, transform.position, transform.rotation);
//This will create the object on top of the object this code is on.
(Help)
var object : GameObject = Instantiate(object, transform.position + Vector3(0, 0, 0), transform.rotation);
//This will create the object at a point by the object this code is on. The three 0 are the (X,Y,Z)
var object : GameObject = Instantiate(object, transform.position, Quaternion.Euler(-0,0,0) );
//This will create the object and set the rotation of the object. The three 0 are the (X,Y,Z)
//Destroy
Destroy(gameObject); //This will destroy the object it's on.
(Help)
Destroy(GameObject.Find("test")); //Destroy other object in the scene, test is the name of the other object.
(Help)
Destroy (gameObject, 10); //Kills the game object in 10 seconds after being created, the 10 seconds can be any time.
(Help)