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 CuriousSheep · Apr 02, 2011 at 12:38 PM · errorcs1502cs1503

Fixed but there is still one error (see code for error) help please :)

using UnityEngine; using System.Collections; using System; //added to access the enum class

public class BaseCharacter : MonoBehaviour { private string _name; private int _level; private uint _freeExp;

private Attribute[] _primaryAttribute; private Vital[] _vital; private Skill[] _skill;

public void Awake () { _name = String.Empty; _level = 0; _freeExp = 0;

 _primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
                                   ;
 _vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
 _skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];

 SetUpPrimaryAttribute();
 SetUpVitals();
 SetUpSkills();

}

public string Name { get{ return _name; } set{ _name = value;} }

public int Level { get{ return _level; } set{ _level = value;} }

public uint FreeExp { get{ return _freeExp; } set{ _freeExp = value;} }

public void AddExp(uint exp) { _freeExp += exp;

 CalculateLevel();

}

//take average of all of the players skills and assign that as the player level public void CalculateLevel() { }

private void SetUpPrimaryAttribute() { for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) { _primaryAttribute[cnt] = new Attribute(); } }

private void SetUpVitals() { for(int cnt = 0; cnt < _vital.Length; cnt++) { _vital[cnt] = new Vital(); } }

private void SetUpSkills() { for(int cnt = 0; cnt < _skill.Length; cnt++) { _skill[cnt] = new Skill(); } }

public Attribute GetPrimaryAttribute(int index) { return _primaryAttribute[index]; } public Vital GetVital(int index) { return _vital[index]; } public Skill GetSkill(int index) { return _skill[index]; }

void AddSkillModifier(SkillName skillName, AttributeName attributeName, float value) {

Skill skill = GetSkill((int)skillName);

Attribute primary = GetPrimaryAttribute((int)attributeName);

// Below is my new error --- error CS1729: The type ModifyingAttribute' does not contain a constructor that takes2' arguments

ModifyingAttribute modifier = new ModifyingAttribute(primary, value);

skill.AddModifier(modifier);

}

private void SetUpVitalModifiers() { //health GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.Constitution), ratio = .5f}); //energy GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.Constitution), ratio = 1}); //mana GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.WillPower), ratio = 1}); }

public void SetUpSkillModifiers() { // Check comments right side -> float m = 0.33f; AddSkillModifier(SkillName.Melee_Offence, AttributeName.Might , m); AddSkillModifier(SkillName.Melee_Offence, AttributeName.Nimbleness , m); AddSkillModifier(SkillName.Melee_Defence, AttributeName.Speed , m); AddSkillModifier(SkillName.Melee_Defence, AttributeName.Constitution , m); AddSkillModifier(SkillName.Magic_Offence, AttributeName.Concentration, m); AddSkillModifier(SkillName.Magic_Offence, AttributeName.WillPower , m); AddSkillModifier(SkillName.Magic_Defence, AttributeName.Concentration, m);
AddSkillModifier(SkillName.Magic_Defence, AttributeName.WillPower , m); AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Concentration, m); AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Speed , m); AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Speed , m); AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Nimbleness , m); } public void StatUpdate () { for(int cnt = 0; cnt < _vital.Length; cnt++) _vital[cnt].Update(); for(int cnt = 0; cnt < _skill.Length; cnt++) _skill[cnt].Update(); }

}

Comment
Add comment · Show 5
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 Mike 3 · Apr 02, 2011 at 01:06 PM 1
Share

Could you post the actual errors? They make it far easier to work out what's wrong

avatar image Bunny83 · Apr 02, 2011 at 02:51 PM 0
Share

If you can't take the time to phrase a good question you won't get any answers. Unity gives you a detailed error message which would be much better than posting error codes... You also get the line number where the error occurred. A short google: 1729 == Wrong constructor parameter count, 1502 == best overloaded function match have invalid arguments, 1503 == can't convert type into type. If you don't tell use where the error have been spotted we can't even say what class is involved. And without seeing the class implementations we can't help you.

avatar image Bunny83 · Apr 02, 2011 at 02:54 PM 0
Share

BTW: what are those ***? did you try to highlight that part as bold and italic? Inside a code block you can't use any markup so you might remove it.

avatar image Justin Warner · Apr 02, 2011 at 03:04 PM 1
Share

Zzzzz good example why you don't s$$anonymous$$l peoples code and use it as your own, because it shows you can't read code, therefore you can't write it, unlike if you take the time to learn, you can write your own, know how it works, and everything/everybody will be merry, but no... So, I suggest you rewrite/learn the code/to code, and THEN if you run in to problems, I'll help you =).

avatar image CuriousSheep · Apr 02, 2011 at 09:12 PM 0
Share

and i wasn't s$$anonymous$$ling the code i was actually working through a tutorial so help me learn!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Statement · Apr 02, 2011 at 03:37 PM

Bash And Slash Error codes CS1729, CS1502, CS1503. What is wrong?

  • CS1729 You supplied too few or too many arguments to constructor.
  • CS1502 You supplied wrong argument type(s) for the method (or constructor).
  • CS1503 You supplied wrong argument type(s) for the method (or constructor).

It is the Under the melee offence bits all of it is errors

public void SetUpSkillModifiers() {
    //Melee Offence
    GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Might), .33f));
    GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nimbleness), .33f));
    //Melee Defence
    GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
    GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .33f));
    //Magic Offence
    GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
    GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.WillPower), .33f));
    //Magic Defence
    GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
    GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.WillPower), .33f));
    //Ranged Offence
    GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));
    GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
    //Ranged Defence
    GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
    GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int) AttributeName.Nimbleness), .33f));
}


Well, Mr. Curious, first off I'd recommend that you break off your insanely long statements into something more manageable, and maybe make a method so you don't have to repeat yourself.

AddSkillModifier(SkillName.Melee_Offence, AttributeName.Might, .33f);

And then create method

void AddSkillModifier(SkillName skillName, AttributeName attributeName, float value) { // This seems ok. Skill skill = GetSkill((int)skillName);

 // This seems to return a System.Attribute, is this intended?
 Attribute primary = GetPrimaryAttribute((int)attributeName);

 // This probably cause CS1729 since it invokes a constructor. 
 // Check your constructor for that type.
 // This could perhaps cause CS1502 and CS1503. 
 // Maybe you're passing System.Attribute where you expected something else?
 ModifyingAttribute modifier = new ModifyingAttribute(primary, value); 

 // This could perhaps cause CS1502 and CS1503.
 skill.AddModifier(modifier);

}

Note that you have imported System namespace. It contains an Attribute class. Perhaps you are having some ambiguity in your code because of this?

With this new method your code should be clearer:

public void SetUpSkillModifiers() {
    // Check comments right side ->
    float m = 0.33f;
    AddSkillModifier(SkillName.Melee_Offence,  AttributeName.Might        , m);
    AddSkillModifier(SkillName.Melee_Offence,  AttributeName.Nimbleness   , m);
    AddSkillModifier(SkillName.Melee_Defence,  AttributeName.Speed        , m);
    AddSkillModifier(SkillName.Melee_Defence,  AttributeName.Constitution , m);
    AddSkillModifier(SkillName.Magic_Offence,  AttributeName.Concentration, m);
    AddSkillModifier(SkillName.Magic_Offence,  AttributeName.WillPower    , m);
    AddSkillModifier(SkillName.Melee_Defence,  AttributeName.Concentration, m); // Melee? Bug?
    AddSkillModifier(SkillName.Melee_Defence,  AttributeName.WillPower    , m); // Melee? Bug?
    AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Concentration, m);
    AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Speed        , m);
    AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Speed        , m);
    AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Nimbleness   , m);
}
Comment
Add comment · Show 1 · 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 Statement · Apr 02, 2011 at 03:41 PM 0
Share

Please also note that you are adding $$anonymous$$elee_Defence where you seem to wanting to be adding $$anonymous$$aic_Defence!

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

Error CS1525 calling OntriggerEnter 1 Answer

Whats wrong with my script? GUI C# 2 Answers

error with GUI in c sharp 2 Answers

error CS1502 and error CS1503 What is this? 1 Answer

Gui label errors 5 Answers


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