- Home /
Spawning Children and Destroying them.
How would I make a child object spawn at a certain location in reference to the parent, and then destroy them. Specifically, I'm seeking to do it with this bit of code:
var hit : RaycastHit; var keyCode : KeyCode; var state = 1;
function Update () {
if (Input.GetKey (KeyCode.X)){ if (Physics.Raycast (transform.position, new Vector3(0,-1,0), hit, 10) ){ if (hit.collider.gameObject.tag=="Ninja") { if (state== 1){ state=1; } if (state==2){ state=1; } } }
}
if (Input.GetKey (KeyCode.Return)){ if (Physics.Raycast (transform.position, new Vector3(0,-1,0), hit, 10) ){ if (hit.collider.gameObject.tag=="Samurai") { if (state==1){ state=2; } if (state==2){ state=2; } } } }
if (state=1){ //script to spawn child object goes here } if (state=2){ //script to destroy children goes here }
}
How would I get this to work?
Answer by Keavon · Oct 25, 2010 at 12:02 AM
Sorry this isn't an answer, but: Wow, that title sounds really... depressing... "Spawning children and then destroying them"
Your answer
Follow this Question
Related Questions
destroy child object 2 Answers
Removing gameobjects 3 seconds after spawning 3 Answers
How can I access the children of a Transform? 5 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Destroy only selected object 1 Answer