x


Disable SCRIPT HELP!!!!

hello i not sure on this i am telling my script to turn of when a new object re-spawns. here is my code:

var spawn : Transform;

//drag your spawn point to here in the inspector - probably make it an empty gameobject so you can move it about on the diving board

//This is the player that it will destroy

var MainPlayer: GameObject;

function Update()

{

if(Input.GetKey(KeyCode.N)){

   transform.position = spawn.position;

    Destroy (MainPlayer);

    GetComponent(NewMoveScript).enabled = false;              

// if i press the N key the new player will respon on the current players position and then // the first player will get destroyed and then the script will disable it self

}

can anyone help please thank you :) }

more ▼

asked Nov 02 '10 at 03:56 AM

MC HALO gravatar image

MC HALO
878 74 94 111

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

1 answer: sort voted first

I hope I have understood your question correctly. I have made some modifications to your script.

//drag your spawn point to here in the inspector - probably make it an empty gameobject so you can move it about on the diving board
var spawn : Transform;
//This is the player that it will destroy
var MainPlayer: GameObject;
//This is the prefab of the new player
var NewPlayerPrefab : Transform;

function Update()
{
    if(Input.GetKey(KeyCode.N))
    {
        Destroy (MainPlayer);
        Instantiate(NewPlayerPrefab,spawn.position,spawn.rotation);
        this.enabled = false;              
    }
}

Is this what you were looking for?

more ▼

answered Nov 02 '10 at 04:07 AM

Atnas1010 gravatar image

Atnas1010
1.1k 6 10 26

Hey thank you but that is doing the same ting as my first script the player re-spawns and the first player destroys it self but the "NewMoveScript" on the player does not disable it self it stays on

Nov 02 '10 at 04:16 AM MC HALO

It does disable itself. If you look at the little checkmark on the script in the Inspector, you can see it gets removed after spawning the new player. If you meant that it should be removed, you should use Destroy(this);

Nov 02 '10 at 04:20 AM Atnas1010

Sorry dude had the script attached to the wrong player loll thank you so much :)

Nov 02 '10 at 04:27 AM MC HALO

You're welcome.

Nov 02 '10 at 04:27 AM Atnas1010
(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:

x3340
x406
x216
x135

asked: Nov 02 '10 at 03:56 AM

Seen: 2885 times

Last Updated: Nov 02 '10 at 04:56 AM