x


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?

more ▼

asked Oct 24 '10 at 09:47 PM

shadowclasper gravatar image

shadowclasper
37 9 9 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Sorry this isn't an answer, but: Wow, that title sounds really... depressing... "Spawning children and then destroying them"

more ▼

answered Oct 25 '10 at 12:02 AM

Keavon gravatar image

Keavon
358 30 34 44

This could probably just have been a comment on the question...

Oct 25 '10 at 12:10 AM Marowi

crap and hit the wrong vote button too -_-;

Oct 25 '10 at 12:40 AM shadowclasper

I wish to know the answer too >..<

Oct 20 '11 at 01:22 PM Vincent_soo
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5060
x764
x408
x135
x110

asked: Oct 24 '10 at 09:47 PM

Seen: 1110 times

Last Updated: Oct 20 '11 at 01:22 PM