• 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 Dovahkiin135 · Apr 01, 2012 at 10:01 PM · characterlives

Character Lives?

I'm making a 2.5D game, like Mario. I want to give my character lives. How? All answers appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Ipsquiggle · Apr 01, 2012 at 10:10 PM

The easiest way is to simple have a "lives" variable on your player character.

Put this at the top of his script:

 var lives : int;

Set the value of this in the editor (to something like 3).

Then, each time he dies, do something like this:

 lives -= 1;
 if ( lives > 0 )
 {
     // Respawn the character
 }
 else
 {
     // Game over! Quit the level or something
 }

You will, of course, have to decide what actually happens during the Respawn and Game Over scenarios, but this will make it choose the right scenario depending on how many lives the player has.

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 kkyriakos · Oct 11, 2016 at 07:59 PM

There are lots of cheap plugins out there that will help integrate lives in your game very easily. I recommend "Life System Pro - Easy Lives Integration for Freemium Games" found here https://www.assetstore.unity3d.com/en/#!/content/69842

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Transform not a child ?? 1 Answer

How to move character to where the "front" of facing.,How to move the player forward to where it is facing? 1 Answer

When I hit play the character rotates 2 Answers

Humanoid IK question. 1 Answer

How do people make an efficient FPS animation/modelling system? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges