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 sam32x · Dec 22, 2011 at 08:38 AM · functionsomethingstupid

function error

here is the line of code with the error: function minusmana () {

the error im getting says: Type "Player" already has a definition for "minusmana".

does anyone know what it means?

here is the whole script:

 var lefthand : Transform;
 var righthand : Transform;
 var spell : GameObject;
 var spell1 : GameObject;
 var spell2 : GameObject;
 var spell3 : GameObject;
 var spell4 : GameObject;
 var spell5 : GameObject;
 var spell6 : GameObject;
 var spell7 : GameObject;
 var spell8 : GameObject;
 var spell9 : GameObject;
 var spell10 : GameObject;
 var spell4u = 0;
 var spell5u = 0;
 var spell6u = 0;
 var spell7u = 0;
 var spell8u = 0;
 var spell9u = 0;
 var spell10u = 0;
 var health = 100;
 var mana = 100;
 var maxHealth = 100;
 var dummy = 0;
 var minusmana = 0;
 
 
 function Start () {
 spell = spell1;
 Invoke("recharge",0.1);
 minusmana = 10;
 }
 
 function recharge () {
 mana += 0.5;
 health += 0.1;
 Invoke("recharge",0.1);
 }
 
 function minusmana () {
 mana -= minusmana;
 }
 
 function Update () {
 
 if (mana >= maxHealth){
 mana =  maxHealth;
 }
 
 if (health >= maxHealth){
 health =  maxHealth;
 }
 
 if(Input.GetButtonDown("Fire1")){
 if(mana >= minusmana){
 Instantiate(spell, lefthand.position, lefthand.rotation);
 Invoke("minusmana",0);
 }
 }
 
 if(Input.GetButtonDown("Fire2")){
 if(mana >= minusmana){
 Instantiate(spell, righthand.position, righthand.rotation);
 Invoke("minusmana",0);
 }
 }
 
 if(Input.GetKeyDown("1")){
 spell = spell1;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("2")){
 spell = spell2;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("3")){
 spell = spell3;
 minusmana = 40;
 }
 
 if(Input.GetKeyDown("4")){
 if(spell4u == 1);
 spell = spell4;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("5")){
 if(spell5u == 1);
 spell = spell5;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("6")){
 if(spell6u == 1);
 spell = spell6;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("7")){
 if(spell7u == 1);
 spell = spell7;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("8")){
 if(spell8u == 1);
 spell = spell8;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("9")){
 if(spell9u == 1);
 spell = spell9;
 minusmana = 10;
 }
 
 if(Input.GetKeyDown("0")){
 if(spell10u == 1);
 spell = spell10;
 minusmana = 10;
 }
 }
 
 function OnGUI () {
 GUI.color = Color.red;
   GUI.HorizontalScrollbar (Rect (Screen.width * 0.1, Screen.height * 0.87, 180, 15), dummy, health, 0, maxHealth);
   GUI.color = Color.blue;
   GUI.HorizontalScrollbar (Rect (Screen.width * 0.1, Screen.height * 0.9, 180, 15), dummy, mana, 0, maxHealth);
 }
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
1

Answer by SkaredCreations · Dec 22, 2011 at 08:48 AM

You cannot assign the same name to both a member and a method.

You currently have both: var minusmana = 0; and: function minusmana ()

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 sam32x · Dec 22, 2011 at 10:08 AM 0
Share

oh ok thanks

avatar image sam32x · Dec 22, 2011 at 10:13 AM 0
Share

also my mana doesnt regenerate, does anyone know why?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

manabar doesnt work 1 Answer

how to make an object "the target" when you click on it 3 Answers

gravity gets too strong and plane falls to the ground help 0 Answers

enemy is destroyed at the start instead of when health is 0 1 Answer

expressions in statements must only be executed for their side effects 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