Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MC HALO · Nov 02, 2010 at 03:56 AM · getcomponentdisableenable

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 :) }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Atnas1010 · Nov 02, 2010 at 04:07 AM

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?

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MC HALO · Nov 02, 2010 at 04:16 AM 0
Share

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 "New$$anonymous$$oveScript" on the player does not disable it self it stays on

avatar image Atnas1010 · Nov 02, 2010 at 04:20 AM 0
Share

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);

avatar image MC HALO · Nov 02, 2010 at 04:27 AM 0
Share

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

avatar image Atnas1010 · Nov 02, 2010 at 04:27 AM 0
Share

You're welcome.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Disable a GameObjects scripts knowing only the GameObjects name 3 Answers

[solved]how can i enable or disable a component of instantiated objects? 5 Answers

Disabling a script in c# not working for some reason 1 Answer

Disabling/Enabling Different Character Controllers. 1 Answer

Disable & Re-enable Script 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges