Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet 2    [LBP2] Help!
#1

Health Bar logic

Archive: 15 posts


Hey guys!

I've created a health system using analogue signals connected to a timer, using batteries to add or subtract set amounts of health. What I'm trying to do is get the health bar to regenerate back to a set level if it falls under a set value i.e. if the player is severely hurt (health below say 10%), but manages to survive without further damage for a short period of time, their health will return to 20%

I've had many ideas but can't seem to get it to work at all, so please if you think you can help it'd be much appreciated!
2012-07-08 17:58:00

Author:
Mopkins
Posts: 123


Hmmm... Not having worked with this method before (just basing my understanding of it off of comphermc's tutorial on the subject), I must admit that I am just grasping at straws here... but would it work to very quickly subtract 100% (get them down to zero) and then add the 20% ?

Or is your question more related to how to know / recognize that they've fallen to or below a certain point?
2012-07-08 19:12:00

Author:
v0rtex
Posts: 1878


I'm more interested in how to recognize that it's fallen to or below a certain point. I've been brainstorming a few ideas since I wrote this using a second timer that I could hide, but your idea seems like it would work assuming I could stop it killing the player. Much simpler at least! Thanks.

If anyone else has a bit more experience than me with feedback loops and analogue signals I'd appreciate any help you could give!
2012-07-08 21:55:00

Author:
Mopkins
Posts: 123


It seems like you're on the money with a second set of logic that works concurrent with the first set of logic, but at 10 less points. That creates the "10 or less" threshold detection you need.

You can't let the main 100/100 meter get to 0/100 and then rise back up without killing the player, but you can have a second set of logic with a meter that goes from 90/90 down to 0/90 wired up to the same system. The player never sees or knows about it. When the player reaches 10/100, the second set of logic is at 0/90, which triggers the timer and eventually turns on a battery that will move the 10/100 health bar up to 20/100. (You'd need further logic for the 0/90 bar to go back up to 10/90 so it could detect things again.)

Does that make sense? It might need a few more selectors and reset counters and things, but... conceptually, that's how I'd do it! Which in hindsight is what you were already thinking about, it seems.
2012-07-09 03:06:00

Author:
Unknown User


Yeah that makes complete sense, it's just getting it to work now! Haven't got around to playing with the idea yet though so I'll let you know if there are any issues with it. Cheers.

The potential issue I can see at the minute is that if the normal health bar falls to say 6%, then I add 10% to both, the second health bar will be a different value. There might be a way using addition to regulate how much is added to each health bar maybe? This is all very new to me, I've never used analogue and feedback loops before in lbp, so this is a massive crash course!

EDIT:
Just had a go at it and keep getting stuck. I've managed to get it to detect when health is below a certain level and then re-add some health (yay!), but I can't get it to do this more than once. I can't think of a way to reset the logic! This is all starting to hurt my brain! Any ideas?
2012-07-09 11:59:00

Author:
Mopkins
Posts: 123


you can wire your timer to a positional sequencer, then place batteries on the sequencer depending on where you want things to activate, then wire the batteries to your add logic.2012-07-10 09:20:00

Author:
evret
Posts: 612


Can you post a picture or two of the logic, with some commentary?

Keep at it and I'll do what I can during my work hours and post some mocked up logic with Photoshop, etc. If the problem persists on Friday I can dedicate some in-game time to it from Friday-Monday (long holiday)!
2012-07-10 10:32:00

Author:
Unknown User


Ooh, didn't think about using a sequencer, I'll have a little look at that evret, thanks!

I'll try and get some pictures of what I've currently got later today, It's a bit of a mess at the minute so I might try and tidy it up a bit first though! I'm grateful for your help anyway! Thanks!
2012-07-10 12:10:00

Author:
Mopkins
Posts: 123


Hiyagain! Thinking back on v0rtex's idea, you might have a solution there where instead of going down to 0/100 and then back up, go back up to 100/100 and then come down! Essentially you're "recharging" the entire health bar in a split second, then reducing it to the set amount. No risk of killing they player and lets you level out at exactly the right amount every time. Perhaps this also makes your reset options easier?2012-07-13 13:22:00

Author:
Unknown User


Oooh it has potential. Depends how visible the quick adding then subtracting is on the health bar I guess. I've all but given up on the idea of recharging health now though, nothing seems to work well enough to make it worthwhile. Thanks for the help anyway!

On the topic of health bars though I have a related query. At the moment the player picks up health packs to regain health as you'd expect, however I can't figure out a way to stop the health packs being picked up when the health bar is full! I'm trying to prevent the health packs being used when they have no effect see. I guess I'm looking for a way to detect when the health bar is full to put it more concisely. Any ideas?
2012-07-13 13:35:00

Author:
Mopkins
Posts: 123


I'm heading into the game now and will experiment with things! Don't look for me online just now, but if you want to friend up for a while so I can see what you're working on and vice versa, that'd be fine. If heavyweight logic experts like evret and v0rtex couldn't suss it, I doubt I can, but somehow I feel like there's a way this can be beat, if with certain concessions made to design.

Will post more tonight/this weekend!
2012-07-13 13:38:00

Author:
Unknown User


I guess I'm looking for a way to detect when the health bar is full to put it more concisely. Any ideas?
wire the timer to a NOT gate, wire the NOT gate to a positional sequencer, place a battery on the sequencer that covers the entire length, wire the battery to another NOT gate.
the output of the final NOT gate will only b active when the timer is at 100%

edit: i really think you guys are over thinking things, this kind of logic is rather basic, i'd personally opt for a feedback loop, just coz it is a lot more versatile, then you could use a feedback timer to display, if you're using the timer for the display that is.
If I were doing it i'd also do it entirely with analog, as i dont like the latency involved with sequencers (i know it's only one frame, but imo thats one frame too much )
I believe Pivottt has a health toolkit level where u could collect a whole range of health logic, even if it's only to learn from it. (havnt played the level myself so i'm not sure of what it contains)
2012-07-13 14:14:00

Author:
evret
Posts: 612


i'd personally opt for a feedback loop, just coz it is a lot more versatile, then you could use a feedback timer to display, if you're using the timer for the display that is.
If I were doing it i'd also do it entirely with analog, as i dont like the latency involved with sequencers (i know it's only one frame, but imo thats one frame too much )

My current health bar already uses a feedback loop with entirely analog signals to add and subtract health. However I'm using tag sensors to pick up health packs, and these need to be switched off whenever the health bar is full (I think?) to prevent the health packs being detected/picked up, which is proving difficult.

@arbiekko I'll give you an add if that's alright, see if 2 minds really are better than 1!
2012-07-13 14:49:00

Author:
Mopkins
Posts: 123


and these need to be switched off whenever the health bar is full (I think?) to prevent the health packs being detected/picked up, which is proving difficult.


wire the timer to a NOT gate, wire the NOT gate to a positional sequencer, place a battery on the sequencer that covers the entire length, wire the battery to another NOT gate.
the output of the final NOT gate will only b active when the timer is at 100%


or to do it with analog only you would just compare the timer to a 100% battery with a combiner, if the output of the combiner is 0% then the timer is full.
u can make a quick analog "greater than 0%' circuit that works well for this kind of thing. just wire your input to a NOT gate, the NOT gate to the top input of a 2 port OR gate, a -100% battery to the bottom input, wire the OR to a splitter.
when the input is 0% the bottom output of the splitter is 0%
when the input is greater than 0% the bottom output is 100%
note- it ignores sign
2012-07-13 15:06:00

Author:
evret
Posts: 612


Awesome! Works a treat. Thanks for the help evret! You're a saviour. 2012-07-13 15:41:00

Author:
Mopkins
Posts: 123


LBPCentral Archive Statistics
Posts: 1077139    Threads: 69970    Members: 9661    Archive-Date: 2019-01-19

Datenschutz
Aus dem Archiv wurden alle persönlichen Daten wie Name, Anschrift, Email etc. - aber auch sämtliche Inhalte wie z.B. persönliche Nachrichten - entfernt.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.