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 Durante · Sep 13, 2011 at 10:48 PM · error

I need help with an error

this is the error i get within unity

(74,36): BCE0120: 'hudController.coin' is inaccessible due to its protection level.

and this is the script

enum PickupType { Grow = 0, Key = 1, Coin = 2, Fireball = 3, ExtraLife = 4, GameTime = 5, }

var pickupType = PickupType.Grow; var pickupValue : int = 1; var itemParticle : Transform; var soundItemPickup : AudioClip; var soundDelay : float = 0.0; var soundRate : float = 0.0;

private var playerGameObject : GameObject; private var hudGameObject : GameObject; private var extraLifeEnable : boolean = false;

function Start () { playerGameObject = GameObject.FindWithTag ( "Player" ); hudGameObject = GameObject.FindWithTag ( "hud" ); } function OnTriggerEnter ( other : Collider ) { if ( other.tag == "collisionBoxBody" ) { var pProp = playerGameObject.GetComponent ( playerProperties );

     ApplyPickup ( pProp );
     
     renderer.enabled = false;
     
     if ( itemParticle )
     {
         Instantiate ( itemParticle, transform.position, transform.rotation );
     }
     if ( soundItemPickup )
     {
         PlaySound ( soundItemPickup, 0 );
     }
     yield WaitForSeconds ( audio.clip.length );
     if ( extraLifeEnable )
     {
         pProp.lives += pickupValue;
         extraLifeEnable = false;
     }
     Destroy ( gameObject );
 }

} function ApplyPickup ( playerStatus : playerProperties ) { var hudConnect = hudGameObject.GetComponent ( hudController );

 switch ( pickupType )
 {
     case PickupType.Grow:
         if ( playerStatus.playerState != PlayerState.MarioFire)
         {
             playerStatus.playerState = PlayerState.MarioLarge;
             playerStatus.changeMario = true;
         }
         break;
     case PickupType.Key:
         playerStatus.AddKey ( pickupValue );
         break;
     case PickupType.Coin:
         playerStatus.AddCoin ( pickupValue );
         hudConnect.coin += pickupValue;
         break;
     case PickupType.Fireball:
         playerStatus.playerState = PlayerState.MarioFire;
         playerStatus.hasFire = true;
         playerStatus.changeMario = true;
         break;
     case PickupType.ExtraLife:
         extraLifeEnable = true;
         break;
     case PickupType.GameTime:
         // playerStatus.AddTime ( pickupValue );
         break;
 }

} function PlaySound ( soundName, soundDelay ) { if ( !audio.isPlaying && Time.time > soundRate ) { soundRate = Time.time + soundDelay; audio.clip = soundName; audio.Play (); } }

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

3 Replies

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

Answer by aldonaletto · Sep 14, 2011 at 12:17 AM

Probably coin is a private variable of hudController - you should declare it as public to be accessible outside the script.

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 Durante · Sep 14, 2011 at 04:19 PM 0
Share

Yes that worked thank you very much to much time looking at lines of code will make you think everything is spelled wrong too...lol

avatar image aldonaletto · Sep 14, 2011 at 11:40 PM 0
Share

This would not produce an error in Unity 3.3, but Unity 3.4 became smarter and now flags these scope errors. Lucky us that I read this when searching in the "What's New in 3.4" doc for another modification (which I never found...)
By the way, @Durante, if this answer solved your problem, please click the "check" button below the voting thumbs to mark it as accepted - the question becomes green and may help others having the same problem.

avatar image
0

Answer by PatHightree · Sep 13, 2011 at 10:52 PM

Try :

public enum PickupType { Grow = 0, Key = 1, Coin = 2, Fireball = 3, ExtraLife = 4, GameTime = 5, }

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
avatar image
0

Answer by Durante · Sep 14, 2011 at 12:09 AM

@ PatHightree

that ddnt work but thank you for your help,@PatHightree

it ddnt work but i greatly app. you trying.

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 aldonaletto · Sep 14, 2011 at 12:35 AM 0
Share

@Durante, please don't use the Your Answer box to post replies or comments - use the add new comment at the question/answers ins$$anonymous$$d. UA is different from forums: answers are for the question only (they are counted) - everything else must be posted with add new comment

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

Assets/Scripts/PlayerController.cs(22,25): error CS8025: Parsing error 0 Answers

need help, with greater than statment 1 Answer

Another Null Reference Exception 0 Answers

Destroy Other 2 Answers

Can't get rid of errors 0 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