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 doomprodigy · Dec 11, 2010 at 01:16 PM · disableenable

Disabling/Enabling Different Character Controllers.

Greetings. I sorted all my problems, now down to my last one for basic gameplay. I have two gun scripts attached my player and I want to enable and disable one vice versa. (Different weapons)

Is this possible? I just am unsure on how to go about it.

Getbuttondown pistol enable pistolscript disable othergunscript. disable ajbfag disable aofbhaobgh disable aofoafa

getbuttondown othergun enable othergunscript disable pistolscript disable ajbfag disable aofbhaobgh disable aofoafa

and so on with other buttons.... enabling and disabling the rest.

I know it is a lot more complex than that but instead of me trying to write one with my limited knowledge on calling and disabling scripts I know I would end up being wrong and coming here.

I know that isint code but that is the sort of thing I want.

Preferably C# but I could probably try to convert it if it is done in Java.

Comment
Add comment · Show 2
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 Scribe · Dec 11, 2010 at 01:32 PM 0
Share

Sorry, quite confused by what your asking. Do you have 5 different guns and you want to change between them after pressing 1, 2, 3, 4, 5 or 'scroll through' your guns by pressing 1 each time

avatar image doomprodigy · Dec 11, 2010 at 01:41 PM 0
Share

It is only two guns currently, the rest were to help understand what I plan on doing once I get the basics of my game down. I the keys will be in a 1,2,3,4..... sort of thing, each key for a different gun

1 Reply

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

Answer by Uriel_96 · Dec 11, 2010 at 03:24 PM

OK this is a little different but it may works. OK so first add an empty object and parent the weapons in the empty object. Then put this script in the player.

var weapons : Transform;
var weapon1 : Transform;
var weapon2 : Transform;
var weapon3 : Transform;
var weapon4 : Transform;
function Update(){
if(Input.GetKeyDown("1")){
weapons.SetActiveRecursively(false);
weapon1.SetActiveRecursively(true);
}
//and there you can continue and continue
}

in the variable weapons put the empty object and in the weapon1,2,3,4 put the weapons

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 doomprodigy · Dec 11, 2010 at 03:52 PM 0
Share

$$anonymous$$ I gave that a go. $$anonymous$$y Player is everything. aside from what the bullets do. THe player contains all the ammo in it's controller script. (The game is 2d). I duplicated the player for testing reasons and did it under the code you gave. It worked by me only controlling one player. And I could switch between them. I did come across two problems though the other play stayed where I spawned or was last using and didn't follow the player I was controlling. And the monsters still chased after it and could damage it. I need it to be invisible and follow me so I can just change weapon if you get me.

avatar image Uriel_96 · Dec 12, 2010 at 03:36 PM 0
Share

sorry, I dont understand, your problem is that it dosent work for 2 players or what????

avatar image Uriel_96 · Dec 12, 2010 at 03:38 PM 0
Share

and sorry I do it in java but I did not read that part :(

avatar image doomprodigy · Dec 13, 2010 at 12:40 PM 0
Share

Allgood now, I worked everything out. Cheers.

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 script from another script 2 Answers

switch scripts? 1 Answer

enable/disable specific components 3 Answers

Another Java to C# Conversion Question!! 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