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 shanereichenfeld · Jan 03, 2014 at 06:12 AM · livehealth

Heath system need help

So i have a "Main Menu" when you click "play" it takes you to a Level selector Screen with all the levels, and you can click on any level and play it. When u play a Level you have 5 heart's that you go threw and if u have zero heart's it restarts the level.

HOW DO I MAKE IT SO WHEN YOU ARE AT 0 HEART'S IT takes 1 out of 3 golden hearts away, and when u have 0 golden hearts you can't play until the golden hearts regenerate. 1 golden heart takes 20 min to generate. BUT I ONLY WANT THE GOLDEN HEARTS TO APPEAR ON THE LEVEL SELECT SCREEN.

heres my code in #c for the level 5 hearts:

using UnityEngine; using System.Collections;

public class EnemyDamage : MonoBehaviour {

 public GameManager gameMananger;
 
 int damageValue = 1;
 
 void OnTriggerEnter(Collider col){
    if(col.gameObject.tag == "Player"){
      gameMananger.SendMessage("PlayerDamaged", damageValue, SendMessageOptions.DontRequireReceiver);
    }
 }

} Also here my Level select Screen in #c

/// /// Level Select. /// Attached to Main Camera /// using UnityEngine; using System.Collections;

public class LevelSelect : MonoBehaviour {

public Texture backgroundTexture;

void OnGUI(){

 //Display our Background Texture
 GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
 
 //Displays our Buttons
 
 if (GUI.Button (new Rect (Screen.width * .1f, Screen.height * .15f, Screen.width * .1f, Screen.height * .1f), "1")) {
    print ("Clicked 1");
    UnityEngine.Application.LoadLevel("Level1");
 }
 
 if (GUI.Button (new Rect (Screen.width * .2f, Screen.height * .15f, Screen.width * .1f, Screen.height * .1f), "2")) {
    print ("Clicked 2");
 }

} }

What do i add to make these changes or how do i make a new script for those new changes?

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
0

Answer by zharik86 · Jan 03, 2014 at 08:17 AM

On how many I understood when HEARTS OF GOLD ended, the player can't restart level. Therefore it should pass into the main menu. Otherwise there will be a restart. So, for example, for HEARTS OF GOLD it is necessary to create a separate class. In it to add static variable:

  public class myData {
   public static int myGoldHeart = 3;

   //metod change count your gold heart
   public static changeGoldHeart(int ch) {
    myGoldHeart = ch;
   }
  }

After that, in that script where there is a restart, it is necessary to add the following condition:

  if (myData.myGoldHeart > 0) {
   Application.LoadLevel("myLevel1"); //restart level
  } else {
   Application.LoadLevel("MainMenu"); // go to the main menu
  }
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

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Apply Damage To Player On Collison With Specific Game Object 1 Answer

Damage taking? 1 Answer

Official Unity Space Shooter Tutorial 1 Answer

health system problems 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