Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tommbomm · Jul 19, 2011 at 06:31 AM · characterclasseshowstats

How to make classes?

Hi i was wondering how you could make classes for your character or just have it so that at the char creation screen you can choose a preset thing of stats thank you!!!!

Comment
Add comment · Show 3
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 MirrorIrorriM · Jul 19, 2011 at 06:33 AM 0
Share

Are classes here program$$anonymous$$g classes, or are they classes in an RPG style game?

avatar image testure · Jul 19, 2011 at 06:50 AM 1
Share

probably both. my eyes are rolling so hard right now.

avatar image Eric5h5 · Jul 19, 2011 at 06:57 AM 1
Share

Please ask a specific question. This is way too general to be answered here, except by saying "You make classes by program$$anonymous$$g them, and it depends on the structure of your game", which probably doesn't help much.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Yoerick · Jul 19, 2011 at 07:21 AM

If you want to start using classes, the best approach would be C# coding. In that case this is how you write a class:

 public class Character
 {
    //some example variables
    private float strength;
    private int charID;
    private float health

    //example constructor which sets the default health
    public Character(float hp)
    {
        health = hp;
    }

    //some example functions
    public void someFunction()
    {
        //do stuff
    }

    public int getCharID()
    {
        return charID;
    }
 }

since you talked about a character and stats I wrote this example with related variables you might be able to use. If you want to make a character you just use Character char = new Character(100); This makes a new character with 100 health for example

Note: if you want to add the script to an object in the scene, the class should derive from MonoBehaviour like so:

 public class Character:MonoBehaviour
 {
    ...
 }

in this case you shouldn't use "Character char = new character(100)" (for example) but just drag the script onto the object.

if you want to make an interface to set the stats of the character you should use the OnGUI function (preferably in another class since this is a seperate functionality, for example a class Interface):

 public class Interface
 {
     void OnGUI()
     {
          // some GUI elements
     }
 }

for GUI scripting I refer to this link: http://unity3d.com/support/documentation/Components/gui-Basics.html

Hope this helps ;)

Comment
Add comment · Show 5 · 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 testure · Jul 19, 2011 at 07:33 AM 1
Share

I applaud your effort, but I get the sinking feeling that this is an uphill battle :)

avatar image CHPedersen · Jul 19, 2011 at 07:43 AM 0
Share

Aww. Don't lose hope! :-D I've +1'ed both this answer and its comment, because I, too, applaud the effort, and the comment made me smile. :)

avatar image Yoerick · Jul 19, 2011 at 07:47 AM 0
Share

Well, I'm guessing he's quite new to program$$anonymous$$g so I just wanted to give him a little support on the program$$anonymous$$g basics and how they work in Unity. Though I think he's got a long way to go if he doesn't know how to program classes.. But if he is deter$$anonymous$$ed to learn, he'll get there :)

avatar image Bunny83 · Jul 19, 2011 at 09:22 AM 0
Share

I would upvote it as well, but you should fix the errors :D

  • the class keyword is lower-case

  • a class don't have brackets behind the class-name

avatar image Yoerick · Jul 19, 2011 at 09:43 AM 1
Share

thanks for pointing that out ;) I didn't write the code in a text editor but in the answer itself and I probably went over it a little too quickly, those were stupid mistakes :p

avatar image
1

Answer by CHPedersen · Jul 19, 2011 at 10:50 AM

There is no global definition of a "Class" that all RPGs use to store their presets. It could be anything you define yourself. What is an RPG "Class" in your game? And by asking, I don't want you to answer me, I want you to ask yourself. Is it the traditional set of Wizard, Fighter, Archer, Thief, Healer, etc? Then, what defines a class? The numbers in Intelligence, Strength, Dexterity and Wisdom? If that is the case, then your preset for a Wizard could be as simple as a textfile called "Wizard" that contains the lines,

Strength: 8 (or something low, for a wizard)

Dexterity: 9 (or something low, for a wizard)

Intelligence: 18 (or something else high, for a wizard)

... You get the point.

Then you can load that into Unity using TextAsset (see http://unity3d.com/support/documentation/ScriptReference/TextAsset.html) and then parse the numbers out of the file. That would be one way to save a preset. On the technical side, there are multiple ways of doing so. You don't have to save it in a textfile, it could also be hardcoded values in your source code, or it could be rows in an SQL table, to think broadly.

On an unrelated note, I get the impression this is a classic case of "I just started Unity, now let's make a game that beats World of Warcraft in a week". ;) Don't take this the wrong way, I'm not trying to shoot you or your idea down. But you might benefit a lot from following some of the many tutorials out there, and then maybe coding a smaller project first. Having done so, you'll realize completely on your own that storing and loading character presets is pretty simple.

Comment
Add comment · 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

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

10 People are following this question.

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

Related Questions

How do I create custom character skins? 3 Answers

I am trying to make a shop system but I am having this doubt 1 Answer

What is the BEST Way to do Character Classes 1 Answer

Need help with Player stats for Choose your own story game 1 Answer

Best way to create multiple characters with the same variables for stats, but different amounts and abilities. 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