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?