x


My object don't spawn as expected so what should I do?

var timeToWait : float = 2;
private var timer : float = 0;
var beginSpawn : boolean = false;
var prefab : Transform; // My object expecting to spawn but it's not.
private var spawnPoint : Vector3;
var SpawnPoint: Transform;// where I want my object to spawn.

// I copied from karl but it's not working and it kept silent and not instantiate the object I expected so how should I go from here please HELP.
Update(){
 while(cur2Health <= 0){
        if(beginSpawn==true)
        {
            spawnPoint = this.transform.position;
            timer += 1*Time.deltaTime;
            if(timer >= timeToWait)     
            {
                Instantiate (prefab, spawnPoint, this.transform.rotation);

                Destroy(gameObject); // This ensures that the instantiation only occurs once
            } 
        }
    }
}

Hi all Unities please help me. O ye this is just fragment of my whole code body even though no compilation error but it just not spawning as expected timer.

more ▼

asked Apr 16 '11 at 02:24 PM

BSVALVE gravatar image

BSVALVE
1 18 20 25

I think you should try to understand the script yourself before asking for help with it. You could start to ask yourself why is there a loop while cur2Health is less or equal to zero .. and what is this cur2Health anyway.

Apr 16 '11 at 02:56 PM Mortennobel

At this moment a bit too lonely just ask some question to break rope. Your answer could be nice if you made it an answered I could + 1 point for you. Thanks anyway I could fixing that problems anyway.

Apr 17 '11 at 08:47 AM BSVALVE
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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:

x1683
x184
x9
x2
x1

asked: Apr 16 '11 at 02:24 PM

Seen: 510 times

Last Updated: Apr 16 '11 at 02:24 PM