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 /
This question was closed Nov 02, 2014 at 05:16 PM by robertbu for the following reason:

Duplicate Question

avatar image
0
Question by The_Unity_Game_Developer · Nov 02, 2014 at 05:16 PM · gui.labelhealth

GUI.Label error.

Hello one and all!

I have started again with my enemy AI and Health script.

I'm trying to use GUI's (such as GUI.Label) to create a visual enemy health, however I always get the error of:

Assets/EnemyAI.js(41,26): BCE0023: No appropriate version of 'UnityEngine.GUI.Label' for the argument list '(UnityEngine.Rect, System.Type)' was found.

I was wondering why this is happening?

Here is my script:

 var health = 10;
 var TakeDamage : boolean = false;
 var fullhealth = Texture;
 
 function OnTriggerEnter(other : Collider)
 {
     if(other.tag == "Player")
     {
         TakeDamage = true;
     }
 }
 
 function OnTriggerExit(other : Collider)
 {
     if(other.tag == "Player")
     {
         TakeDamage = false;
     }
 }
 
 function Update()
 {
     if(TakeDamage)
     {
         if(Input.GetButtonDown("Fire1"))
         {
             health -= 1;
         }
     }
     if(health <= 0)
     {
         health = 0;
         Destroy(gameObject);
         Debug.Log("Enemy is dead!");
     }
 }
 
 function OnGUI () {
     if(health >= 10)
     {
         GUI.Label(Rect(10,40,100,100),fullhealth);
     }
 }


So basically if the health is equal to or more than 10, it will display the fullhealth texture.

Thanks in advance!

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

  • Sort: 
avatar image
0

Answer by robertbu · Nov 02, 2014 at 05:17 PM

Line 3 should be:

var fullhealth : Texture;

...with a ':' not an '='.

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 The_Unity_Game_Developer · Nov 02, 2014 at 05:30 PM 0
Share

Thanks! Just a simple error after 3 hours of sleep I guess. Hehe!

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How do i get the player to shrink according to the health? 1 Answer

How to damage player when bullet collides with player. 0 Answers

My integer for my player health seems to be only returned once 2 Answers

MouseOver GUI.Label Information 1 Answer

hide gui.label after an event 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