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

Crazy Health Bar Question

Archive: 12 posts


All right, I have a complicated logic piece I need help with.

I am trying to create a health bar, only this time I want to use a Timer to create it. Normally, this would be easy. Set it to start/stop, when a player is getting 'Hurt' the timer goes up. When it's full, it kills the player.

However, that is not how I want it to work.

I want there to be no less than five actual health-bar chunks that change color depending on your HP. I'm thinking like, hook each one to a timer with the dimmer option, so they'll go green to red, and then when they reach full red, an opacity tweaker hides them.

This is my best guess for how this logic would work:
Red Tag Sensor -> Timer 1 (Start/Stop) -> Opacity Tweaker
Then....
Timer 1 (Start/Stop) -> AND Gate (with) Red Tag Sensor -> Timer 2 -> Opacity Tweaker
Then....
Timer 2 (Start/Stop) -> AND Gate (with) Red Tag Sensor -> Timer 3 -> Opacity Tweaker
Then....
Timer 3 (Start/Stop) -> AND Gate (with) Red Tag Sensor -> Timer 4 -> Opacity Tweaker
Then....
Timer 4 (Start/Stop) -> AND Gate (with) Red Tag Sensor -> Timer 5 -> Opacity Tweaker + Kill Tag (Which plays a cutscene showing the player dying.)

------

Now for the tricky part. I also need to figure how to manage health powerups. I need each health power up to reset ONE timer's bar, and only the 'current' timer. So it's in reverse order.
One HP powerup resets Timer 5.
The next one resets Timer 4.
The next one resets Timer 3 and so on...

How would I accomplish this?


------- I thought of a way that's even more convoluted, but might work. -------

When each HP node is full, it activates a labeled 'HP' Tag.
So like, Timer 1 turns on HP (Purple), Timer 2 turns on HP (Blue), Timer 3 turns on HP (Green), Timer 4 turns on HP (Yellow), Timer 5 turns on HP (Red)

None of the Timers are directly linked to each other anymore. Instead, their AND Gates detect the previous HP Tag alongside the damage indicator tag.

The Reset for each timer, also requires an AND gate, with several "NOT" gates linked into it.

Timer 5's Reset AND Gate Looks For...
- HP Restoration Tag
- Timer 4's Tag

Timer 4's Reset AND Gate Looks For...
- HP Restoration Tag
- Timer 3's Tag
- NOT Timer 5's Tag

Timer 3's Reset AND Gate Looks For...
- HP Restoration Tag
- Timer 2's Tag
- NOT Timer 4's Tag

Timer 2's Reset AND Gate Looks For...
- HP Restoration Tag
- Timer 1's Tag
- NOT Timer 3's Tag

Timer 1's Reset AND Gate Looks For...
- HP Restoration Tag
- NOT Timer 2's Tag


------- AND NOW YOU ARE ALL CONFUSED AND I'M SORRY! -------
2015-08-04 19:47:00

Author:
Kato
Posts: 732


This will surely be answered by the time I get a chance, but I'll look at it anyway when I get home coz lbp

Edit: while this could be done with timers, i'd suggest using a feedback loop for health, then separate the signal out for each segment of your display, then multiply each to get the full 0-100 range needed for the dimmer on each segment.
there are a few health tool kits around that could help with this, or if you're willing to wait a few days i should be able to throw it together for you, to either give to you directly or show you how in a video.
2015-08-05 03:15:00

Author:
evret
Posts: 612


I'm ... going to attempt my Tag idea first. Sorry, you're speaking a logic language I do not understand. XD

For me the pinnacle of my logic brilliance was figuring out that adding labels to tags makes them unique.... so.... what you're proposing is WAY too advanced for me.
2015-08-05 15:11:00

Author:
Kato
Posts: 732


Here's a good way to do this:

Use the opacity settings you fore-mentioned to tweak the timers' visibilities, but only use these timers for display. Have a hidden health feedback loop system that is behind all of the timers, creating the actual health; use the timers for display only.

Next, using a feedback loop system, have it test in intervals of (x/5), and use that for display (you have to compare the feedback loop output to see if it is >= (x/5) )

Finally, input a heal mechanism that restores feedback loop systems 1/5 of health, successfully masking the illusion of the health system behind the timers.

Some tutorials that may help you:

Feedback loops (https://lbpcentral.lbp-hub.com/index.php?t=86815-learn-the-feedback-loop-seriously)
Value comparison(1) (http://www.lbpcentral.com/forums/entry.php?11052-Comparing-analogue-values-(FIRST-BLOG-POST))
Value comparison(2) (https://lbpcentral.lbp-hub.com/index.php?t=90812-Best-way-to-compare-percentages)
2015-08-06 18:50:00

Author:
amiel445566
Posts: 664


Uh...

This is still a logic language I do not understand. I am not a logic expert. XD;;; I'm reading this and it's WAY over my head....

Even so, I'm not certain this is what I'm looking for either. Your health in the level I'm making is MEANT to be calculated in seconds. Like, you've got 25 seconds before you catch on fire. Or you've got 25 seconds before you freeze to death.

I don't want a typical "You got shot, you lose a health point" thing. I want an actual "You've spent too long standing next to a ghost, and now you're having a heart attack".

-----------

The breakdown of what I want.

- You have 25 total seconds of 'Life"
- Your Life only decreases when you're in a danger zone.
- Visually, this is represented as five green HP Bubble Icons.
- Each bubble represents 5 seconds of life.
- As your seconds run out, the bubbles change in color from Green to Red before vanishing completely, in order.

All the above I can do. Here's where it becomes tricky.

- HP Pickups restore one bubble of health. (Five Seconds)
- HP Pickups are instantaneous.

The problems I've encountered are:

- HP Pickups only restore not only the current bubble, but also the most recently 'emptied' bubble.
- So like, if Bubble #3 is completely empty, and Bubble #4 is only half empty, a health pickup will restore both #3 and $4.

So my options are..
A: Live with it.
B: Let all health pickups fully restore your life.
C. Find an alternative.
2015-08-06 20:16:00

Author:
Kato
Posts: 732


This sounds very interesting. I love the idea!

So am I to understand the rest of these health bubbles is really the only problem?

Without seeing your logic I can't be sure, but I would wager that your signal, probably from a tag sensor, is staying on too long. Add a pulse counter if this is the case.

A pulse counter is a regular old counter set to 1 instead of the default 10. Take the counters output and wire it into it's own reset. Done.

Tag sensor - pulse counter - the rest of your logic.

What this does is change your sensor signal into a 1 frame pulse no matter how long the sensor is active. 1 frame = 1/30 of a second.

If this doesn't fix it, the problem is something else.

Also watch those tutorials they are good.
2015-08-06 23:01:00

Author:
one-mad-bunny
Posts: 334


*cracks knuckles* Here we go

So, if I am understanding this correctly, you want something like this

http://www.lbpcentral.com/forums/attachment.php?attachmentid=49912&d=1438895738
If that is what you want, then here is my understanding about how to go about it (put as simply as I can manage)

The first thing you should do is to come to terms with how a feedback loop works, some great tutorials are the ones fore-mentioned in the above post of mine, and the tutorials by Comphermc:


https://www.youtube.com/watch?v=c4GaCQ1eRVE

https://www.youtube.com/watch?v=k0sbxogAcDo

It is necessary to use feedback loops here if you don't want a complex system. Feedback loops, although intimidating at first, actually make logic much more compact, especially health.

I don't want to reiterate some of my tutorials on feedback loops, and restate the already well put words of others, so I'll leave you to understand those tutorials (or try to), and if you manage to understand them, then continue to the next part where I talk about how to implement these feedback loops into your health system

What you want to do (after understanding the prerequisite knowledge of feedback loops), is to set up a system that lets you add in damage freely, but heal in sections of fifths

To do this, have a feedback loop system set up like so

http://www.lbpcentral.com/forums/attachment.php?attachmentid=49913&d=1438898712


Then using the comparison tools from the fore-mentioned tutorials, you can get 5ths to display for your bar. Using the dim function, you could get it to work how you want. Along with these sectioning comparisons, you could use the same chip to test if the object is *dead*, and through that, you have a functioning health system, the way you want it to function
2015-08-06 23:11:00

Author:
amiel445566
Posts: 664


Uh...

This is still a logic language I do not understand. I am not a logic expert. XD;;; I'm reading this and it's WAY over my head....

Even so, I'm not certain this is what I'm looking for either. Your health in the level I'm making is MEANT to be calculated in seconds. Like, you've got 25 seconds before you catch on fire. Or you've got 25 seconds before you freeze to death.

I don't want a typical "You got shot, you lose a health point" thing. I want an actual "You've spent too long standing next to a ghost, and now you're having a heart attack".

-----------

The breakdown of what I want.

- You have 25 total seconds of 'Life"
- Your Life only decreases when you're in a danger zone.
- Visually, this is represented as five green HP Bubble Icons.
- Each bubble represents 5 seconds of life.
- As your seconds run out, the bubbles change in color from Green to Red before vanishing completely, in order.

All the above I can do. Here's where it becomes tricky.

- HP Pickups restore one bubble of health. (Five Seconds)
- HP Pickups are instantaneous.

The problems I've encountered are:

- HP Pickups only restore not only the current bubble, but also the most recently 'emptied' bubble.
- So like, if Bubble #3 is completely empty, and Bubble #4 is only half empty, a health pickup will restore both #3 and $4.

So my options are..
A: Live with it.
B: Let all health pickups fully restore your life.
C. Find an alternative.

While I prefer feedback loops, timers are more than adequate for your situation, and have the benefit of being able to wire them directly to sticker panel or holo set to dimmer.
Just a few tips to help you with your issues.
If you invert the timers- the reset input will fill it completely and the regular input will make it count down/lose health.
Wire the timer to a sequencer set to "positional", place a battery on the sequencer's board and make it the same length as the board, then wire the battery to a NOT gate beside the sequencer. This NOT gate will only be on when timer is empty.
Copy and paste another sequencer below the first, wire the timer to a NOT gate, wire the NOT to the second sequencer, then wire the sequencer's battery to another NOT gate. This NOT gate will only be on when the timer is full.
Knowing when the timers are full and empty should make the rest pretty straight forward, you can also use selector priority to eliminate a lot of AND gates. (when multiple inputs are active, the one closest to the bottom is the only output to turn on)
2015-08-07 03:16:00

Author:
evret
Posts: 612


While I prefer feedback loops, timers are more than adequate for your situation
I thought that too, but because of

- HP Pickups only restore not only the current bubble, but also the most recently 'emptied' bubble.
- So like, if Bubble #3 is completely empty, and Bubble #4 is only half empty, a health pickup will restore both #3 and $4.

feedback loops have that versatility of being able to detract any value at any time. Made lightweight enough, you can have efficiency in thermo, and remove this problem. Your method is really lightweight though evret, it's just this one issue that makes the feedback loop more formidable in this situation.
2015-08-07 04:29:00

Author:
amiel445566
Posts: 664


I thought that too, but because of

this is why i mentioned the selector in my previous post, it would ensure that only one would be reset at a time, another would make sure only one timer is counting down at a time


feedback loops have that versatility of being able to detract any value at any time. Made lightweight enough, you can have efficiency in thermo, and remove this problem. Your method is really lightweight though evret, it's just this one issue that makes the feedback loop more formidable in this situation.

If kato was asking for a highly versatile solution then i would suggest that taking the time to learn the inner workings of lbp's analogue system would be worthwhile, however kato mentioned several times that feedback loops were beyond his understanding right now and would prefer a solution that used timers for health instead.
timers are capable of doing this, so there is no need to pressure him into spending the time to learn a method that would be overkill in this situation.

feedback loops would be my preferred method too, but timers would benefit kato more in this situation as he already has experience with them.

I use analogue all the time, but many good creators dont use it at all, so dont feel like you need to learn it to make good levels.

- - - - - - - - - -

ok, so this is my timer based solution

http://www.lbpcentral.com/forums/attachment.php?attachmentid=49917&d=1438947357
49917

sequencers are set to "positional"

batteries are 100% (all sequencers have a battery the same length as the board as shown in the one i left open)

opacity tweakers are set to strength scale so they fade as the colour turns red

sticker panel is set to"dimmer", red and 100% brightness when on, and green 100% when off.

counter on bottom left is set to 1 and wired to reset itself, activate this to refill current timer. (health pickup)

wire your impact/tag sensor to the top left Not gate, this will drain health at the rate set by the timers. (set to 5 seconds to drain one bar every 5 seconds etc.)

and finally- the top right NOT gate's output will activate when health is completely depleted.
2015-08-07 12:52:00

Author:
evret
Posts: 612


Really, I'm confounded how you fine folks are able to figure these things out. XD I'm also super grateful you're all so nice and willing to help. Thank you!

I'm not denying the usefulness of feedback loops or anything. I'm only saying that I don't yet know understand these things work, what they do etc. Just consider me fresh from Little Big Planet 1 where I had to put wheels on an actual material piece with tags and have it roll by tag sensors to get sequencer functions, lol. There are TOTALLY better ways of doing logic. I just don't know them yet. So thank you for being patient with me!

I'll check out these solutions, and see if I can get them to work. This is the one I'm currently working with.
http://www.demon-heart.com/random/Logic.jpg

EDIT: Just to note, the Sticker Materials are set to Dimmer, while the Opacity Tweakers are set to On/Off. This way the bubbles stay 100% visible until it is time to vanish!


'Nother Edit:

Evret you beautiful human being you. thank you so much for the help. Thi8s works exactly how I want it to. EXACTLY. And best of all, I don't have to fiddle with any thing too advanced to destroy the medkits once you use them. You just give them a grab and bam, health.

Really this is perfect! This is going to help this level out significantly. And now I no longer need to give up on any of my glorious plansssss. XD Than you again. Thank you everybody. This is just what I needed.
2015-08-07 16:44:00

Author:
Kato
Posts: 732


EDIT: Just to note, the Sticker Materials are set to Dimmer, while the Opacity Tweakers are set to On/Off. This way the bubbles stay 100% visible until it is time to vanish!

i think it looks better when they fade, but thats just me i guess



'Nother Edit:

Evret you beautiful human being you. thank you so much for the help. Thi8s works exactly how I want it to. EXACTLY. And best of all, I don't have to fiddle with any thing too advanced to destroy the medkits once you use them. You just give them a grab and bam, health.

Really this is perfect! This is going to help this level out significantly. And now I no longer need to give up on any of my glorious plansssss. XD Than you again. Thank you everybody. This is just what I needed.

no worrys dude, i like these kind of problems that call for me to look for a solution from a different angle. i believe this is also lower thermo than any analogue alternative for this particular problem

- - - - - - - - - -

Looking at this again, you could actually just remove all the sequencers and it would work the same, as timers will only be filled with the reset they will always have a digital output when there is health left. I used the sequencers because I am used to both adding and subtracting using timers set to "speed scale" where digital wouldn't always be on while health is present.

another edit:
you can remove the top row of sequencers but not the bottom.
if you remove the bottom ones it will only refill timers that are completely empty
2015-08-08 09:36:00

Author:
evret
Posts: 612


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.