Adding health to a player

0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • <font color="red">I think I may have figured it out. Currently testing.

    Yep figured it out. Turns out I wasn't thinking things through. I know this is probably an extremely basic thing but I'll write out how I did it just in case someone searches for this exact same thing (what are the chances someone doesn't know how to do this right? lol /facepalm)</font>

    <font color="green">Give your player character an instance variable with however much health you want him to have. Create an event and select your player character, scroll down to instance variables and select compare instance variable. Select your characters health instance variable from the drop down menu (if it doesn't appear you didn't create one). Under comparison select Less than or equal and for the value select 0. Next add an action, select your player, scroll down to misc and select destroy. This says that when your characters life is less than or equal to zero, destroy him. Just follow the other tutorials if you want to create a health display. But in short create a global variable with the same value as your players starting health, then every time your player gets hit subtract 1 from the global variable as well. I don't know how to do it for platform games where you give them multiple retries, this is more for games similar to the Ghost Shooter beginners tutorial.</font>

    ====== Original Post =======

    Hello again and sorry for asking for help again so soon. I want to add health to my player and display it as well. The problem is that when I try to set text it doesn't accept instance variables? I honestly can't even believe I'm having issues figuring this out. I thought this would have been the easiest part.

    I have an instance variable for the player sprite called PlayerHealth set to 25. I created a text object called PlayerHealth as well. When I try to set text "HP: " & PlayerHealth to display the HP it says 'PlayerHealth' needs an expression after it, this is an object name so you need a dot and an expression name after it.

    I tried to make a global variable instead of instance for the player to use but I can't add that to the player.

    Basically I want to subtract health when monsters collide with the player, not instantly destroy the player, and it seems I can only use instance variables to do that but I am not sure how to get the health to display. I know I'm missing something, or several things, but I am not sure what. Any chance someone can help out?

    Right now this is what I want to add to the player:

    Or by using the usefull clamp

    http://dl.dropbox.com/u/23551572/C2/clampHealth.capx

    I get that it's only a display (which is using global variables), I just don't know how to actually add health to the player properly so it gets subtracted when monsters collide with the player.

  • healthBar.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The best part is when you start figuring out how things work! I treat it like meta-game developing, and I'm gaining experience! :)

  • The best part is when you start figuring out how things work! I treat it like meta-game developing, and I'm gaining experience! :)

    ^^ this is the purpose.

  • <img src="http://mmgaming.net/wp-content/uploads/2011/11/Double-Facepalm.jpg" border="0" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)