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 superpentil · Aug 18, 2012 at 08:08 AM · prefabsmultiplayer networking

Create-a-Class?

I want to be able to have multiple classes (or loadouts) for my game. Is there anyway I can do this? One idea i had would be to store the original prefabs in the deep parts of the game then as you level up and get more things you can bring up that model that has an extension on it. I want this to also affect one person not a whole bunch of people. (im trying to get my hand at multiplayer scritping and i dont get how to make the script affect only one person (but thats another question). So How do i get this create a class function working here?

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
0

Answer by fafase · Aug 18, 2012 at 08:16 AM

I don't get quite well everything you say so I will answer with what I understood.

You can create classes, simply create a script with the declaration of a class and the other one will automatically access:

In one script

 class Boy{
    var age:int;
    var toy:String;
    function Boy(a:int,s:String){// Constructor
       age = a;
       toy =s;
    }
    function Play(){
       print(name+" is "+age+ " and plays with his "+toy);
    }
 }
 class Girl{
    var age:int;
    var toy :String;
    function Boy(a:int,s:String){ // Constructor
       age = a;
       toy=s;
    }
    function Play(){
       print(name+" is "+age+ " and plays with her "+toy);
    }
 }

Then anywhere else:

 var steve = new Boy(10, "GIJoe");
 var kelly = new Girl(8, "Barbie");

Now each of them will be a total different object in memory with special addresses for each variable.

Then you can use the variables like:

 steve.toy = "Lego";
 steve.Play();
 kelly.age = 22;
 kelly.toy = "well...";
 kelly.Play();

Is that what you meant?

Comment
Add comment · Show 2 · 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 superpentil · Aug 18, 2012 at 09:12 PM 0
Share

I don't mean how do you declare a class in script(Though thanks because I'm sure i'm going to need this knowledge sooner or later) But what I mean is if you play a game like Call of Duty the feature Create-a-Class where you make custom loadouts is what I'm talking about here.

If you dont know this will explain it: http://callofduty.wikia.com/wiki/Create-A-Class

avatar image fafase · Aug 19, 2012 at 05:43 AM 0
Share

I would think the principle remains the same. You have the class and a particular action, clicking a button in a zone of the menu, will create the object with the information you gave. Those info could be free or a choice within an enumerator. Later you would have to save the info. This is not impossible but that is quite a long process since you need to declare all the possible choices, create the GUI and the saving system.

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Find Script from another script 2 Answers

Changes to variables in script not being modified on objects attached to 1 Answer

Share a script between prefabs - like inheritance 1 Answer

Insert a prefab into scene in a script? 1 Answer

How can I combining two players to make one ? 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