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

100 point Health and energy bars. Help please!

Archive: 14 posts


Hello all. as of late I have (1st LBP 2 Level!) been trying to get a "free-running" sackbot going. its more magic than free running. however. right now I have 2 "moves" as such that I wish I could limit via energy. I currently have them set up to a small timer powered cool-down system that doesn't quite float my creative boat. I want it to have a 100 count bar that constantly increases. (a clock, maybe? (timer set to reset itself)) with each "move" (a super jump and a sprint) to take 15 and 20 energy respectively. basicly. it has 100 counts. it loses 15/20 (depending) each time you lose it and when there is not enough energy left over. you cannot use it untill there is enough "energy" (its magic. dont tell them I said that though) to activate it (did I explain well enough?)

With the health bar. well. its a health bar. what can I say. I do hope you guys can help me out with this as I'm stuck. and theres no holding X on a button to get out of holes with logic! except the community. thanks in advance. hope this is possible.

_-_-Huntedstorm-_-_
2011-08-01 12:30:00

Author:
huntedstorm
Posts: 488


Health Bar is all I know. Whatever the enemy attack you add a tag to it and have a tag sensor on your sackbot. Set it up to a timer and set the timer to a destroyer, so now for as long as the tag is activated the health bar will deplete. Now put a timer down but visible and on a piece of holo set to follow the sackbot. Invert it and put it to the same time as the other timer. It should be full (full colour not blank counting up, it counts down) set the same tag sensor to it and now it will do nothing. But it will represent the one on the sackbot.2011-08-01 12:35:00

Author:
craigmond
Posts: 2426


100 points equals 100% so you can use a battery set to 1% in a feedback loop system hooked up to a timer set to 0.1 seconds... EASY

Actually half of what I said DOES make sense. Check out this super slick video (http://www.youtube.com/user/LBPlanetorials#p/u/3/c4GaCQ1eRVE) for a scary (but not overly so) setup.

I have actually been messing with it to include stages of regen that actually cap out when the bar reaches 75%. This percentage check could be altered to stop a 20% move from being activated if there is less than 20%... To be honest I didn't think of that... hmmm I'll see if I can add that.

ANYWAY It's working in its initial build I should have a better version soon if you have trouble, setting it up.
2011-08-01 12:48:00

Author:
Mr_Fusion
Posts: 1799


There is no way that i know of to make a counter lose or gain more than 1 of its count in a single simulation frame because it increments/decrements via the digital out of a signal, which by definition needs 1 frame to propagate an ON state ,and another to propagate an OFF state ready for the next ON signal. The problem with this is times quickly add up, if it takes 15Hz to complete one of these cycles (or 0.066 seconds ~ 2 simulation frames of the engine running at 30Hz) 15 of these takes 0.99 seconds (lets say 1 for ease) and 20 takes 1.32 seconds. Depending on how you have your game set up and how quickly things happen, this might throw timings off and eventually you may get inaccurate results if a new input is triggered to enter the register within the time frame a previous input is still being 'unloaded' into the register over a number of frames, to solve this you will then need some kind of signal storage buffer, which is where things get rather complicated, not to mention an inherent lag as the register will periodically be trying to 'keep up' with the gameplay.

To keep things much more simple, there is a way to increment/decrement an analogue register in game in a single frame in much larger chunks than 1% intervals per 15Hz (which is what using a counter set to 100 would be), the limitation here is 33% of the maximum value per simulation frame. Luckily as your highest intended increment is 20%, we have a realistic solution.

Things you will need:


A Timer set to 0.1 seconds, also set to 'speed scale'. (this is your analogue register)
A number of Pulse Gates (a counter set to 1 plugged into its own reset) corresponding to the number of different value changes you intend to effect the register with, in your case, 2.
A corresponding number of Timers, these will be your value change sources, the signal you will use to 'pulse' into the register.
A corresponding number of AND gates, these are used to connect the pulse gates with the value change sources (timers).
Some form of logic to trigger the system.


Before we go into detail I'll explain a little of the underlying theory. The 'speed scale' function of the timer implements a change in the timers stored value at a rate proportional to the magnitude of the input signal. For example, A timer set to 10 seconds with an analogue value of 50% being input will take the timer 20 seconds to fill.

This same behavior, when regarding a timer set to 0.1 seconds and speed scale, and being 'pulsed' a specific signal for 1 simulation frame will change the stored value proportional to [the input value divided by 33% (1/3) of] the maximum value. For example pulsing a 100% signal into this set up for one simulation frame will increase the timer by 33%, or, pulsing a 50% signal into this setup for 1 simulation frame will increase the stored value by 16.5%.

This is because the LBP engine runs at 30Hz, or 30 frames a second, or 0.033 seconds, meaning there are 3 frames for every 0.1 seconds. Because the lowest setting on a timer is 0.1 seconds, and a Pulse gate is active for exactly 1 simulation frame, 1 third of the minimum value applicable to a timer, this is a limitation we have to work around, hence the 33% of maximum value per simulation frame.

You can accurately increase or decrease the value in a timer in one simulation frame as much as you want, as long as it falls below the 33% limitation.

Now you understand the basic underlying principle here, the next thing we need to do is work out what 15% and 20% of 100% is in terms of the stored value in a timer we will be using to pulse into the register. Remembering to get the desired result, we need to effectively multiply the initial result by 3.

A quirk with timers is they are actually quite inaccurate, refer to this page (http://wiki.lbpcentral.com/Talk:Timer) to see some of the imperfections in the timers calculations. Without going into too much detail here, the only thing you need to know is N*3 (Basically any multiple of 3) integers work accurately with timers. (Its something to do with numbers accurately expressible in the ieee 754 standards (http://steve.hollasch.net/cgindex/coding/ieeefloat.html) ( or (http://en.wikipedia.org/wiki/IEEE_754-2008) ) which the LBP engine uses to calculate things, when the 30Hz limitation of calculating values is taken into account. I don't know enough about it to be sure, but the apparent coincidence between 30Hz and multiples of 3 seems quite interesting) - if I'm completely wrong about this and it has nothing to do with IEEE 754, can someone (AYAH!) come and correct me on this point.

Digressions aside, 12,000 is a multiple of 3 so we can use 12,000 in our system as a representation of 100% and be sure that integers of this when propagated and stored in timers will be accurate. So the first thing we do is set our 'value change' timers to a maximum time of 12,000.

Now we need to work out what 15% of 12,000 is. To do this we need to take the number representing 100%, divide it by 100 then multiply it by the the same value as the percentage we are looking for.

In this case it is 12,000/100*15, which equals 1,800. But remember we will only be getting 33% of this value (15%) for each pulse of the inputting signal (which will actually only be 4.5%), so we need to multiply our stored value representing 15% by 3 in-order to work round the interval difference between 0.033 second input of the pulse gate and the 0.1 second set analogue register.

So the actual sum is [(12,000/100*15)*3] = 5,400. So to increase (or decrease) the stored value in our register by 15%, we want to pulse into it for 1 simulation frame, a Timer with a maximum value of 12,000, and a current time set to 5,400, which is handy as 5,400 is also a multiple of 3 with no remainder, keeping everything quite neat and accurate.

So having got this far, we now have our analogue register (timer set to 0.1) and one of our 'value change' timers (max 12,000 ~ current 5,400).

For the 20% value change timer, we go through the same process: [(12,000/100*20)*3] = 7,200. ( as a check-sum [(7,200*5)/3] = 12,000 ) 7,200 is also a multiple of 3 with no remainder, yay! (lol, there is a mathematical relationship at play here, its not coincidence)

So take your second value change timer and set its maximum time to 12,000 ~ Current time 7,200.

Ok, now we have all the crazy math out the way we can get to building the thing!


First, you need to make sure your 'value change' timer's values don't change, to do this simply get any logic gate out of your tools bag, take the output, drop a node then loop the node's output round to its input, remove the logic gate, take the node and plug it into the input of your timers. This is basically a very thermo friendly way of making sure the timers are always set to 'off' and don't change their values at any point.

Take your 'value change' timers, Your Pulse gates, and An AND gate for each pair of Pulse gates and value change timers.

Plug each pair of 'value change timers' and pulse gate into both inputs of an AND gate respectively. You should have 2 sets of these, one representing your 15% pulse input, another representing your 20% pulse input.

Next OR the two outputs of each AND gate together with in OR gate.

Go into your tools bag and pull out a Direction Combiner (http://wiki.lbpcentral.com/Direction_Combiner). This component allows you to 'flip' the sign of the input signal. Up until now we have been dealing with positive values, but because we want to be 'decreasing' the amount in the timer, we want a negative signal don't we.

Plug the output of the OR gate into the NEGATIVE [ - ] input of the Direction Combiner.

Now plug the output of the Direction Combiner into the Input of your Analogue register (Timer set to 0.1 ~ Speed scale)

To actually trigger the pulses to alter the value in your register, you need to plug which ever logic you use to trigger the abilities in your level into the PULSE GATE'S INPUT corresponding to each value change timer respectively.
When you do this it will trigger the analogue signal to pass through the AND gates. Because the analogue signal of the Counter is actually 100%, and the AND gate performs a ()MIN function (that is, it only lets the SMALLEST of all input analogue signals through its output), only the analogue signal from the 'value change timer' will reach the Analogue Register.


Now we have the basic decrement system in place, I suppose you'll also need a way for the Register to increase in stored value, allowing your 'stamina' (or whatever you've called it) to rebuild over time.

This depends on how you quickly you want that to happen. You can simply plug another of these 'value change timers' into the positive [ + ] input of the Direction Combiner, remembering that for each frame it will increase the value in the timer "proportional to [the input value divided by 33% (1/3) of] the maximum value".

As there are 3 frames every 0.1 seconds, we can work out how much of a signal we need to input for every frame that corresponds to an arbitrary timescale (in seconds) it would take to fill the Register to 100%.

Without going into detail about how this is worked out (because its quite complicated). These are the times and corresponding values it takes to fill the Register from 0 to 100%:

All timers below are set to have a maximum time of 12,000.0 (as with every timer in this guide except the Analogue register which has a time of 0.1)

Current time ~ 20.0 seconds: Takes the Register exactly 1 minute to fill
Current time ~ 40.0 seconds: Takes the Register exactly 30 seconds to fill
Current time ~ 80.0 seconds: Takes the Register exactly 15 seconds to fill
Current time ~ 160.0 seconds: Takes the Register exactly 7.5 seconds to fill
Current time ~ 320.0 seconds: Takes the Register exactly 3.75 seconds to fill

-----------

Before I finish i would like to point out that if you intend on using a 'power' that takes 15% (or 20%) from the stored amount, there may be a point in playing where you have only an amount 15% or below, yet you would still be able to use a power as there is still signal left in the Register.

To stop this, plug the output of the Register into a sequencer set to 'positional', open up the sequencer and make it 20 stripes long. Now each stripe corresponds to 5% analogue signal.

On whatever logic you have to trigger your skill that takes 15%, place a battery on the sequencer, beginning at the start of the THIRD stripe, make it run the entire length of the sequencer, plug the ouput of this battery into an AND gate and have the other input of the AND gate whatever is triggering the use of the skill.

Do the same for the skill that uses up (and requires) 20%, this time placing the battery so it begins at the beginning of the FOURTH STRIPE, plug this into an AND gate and plug whatever logic you have triggering the skill into the other end of the AND gate.

Plug the outputs of these AND gates into whatever the skill triggering logic was originally plugged into.

This will basically stop the use of either skill if the amount in the register falls below the required amount for using that skill.

Thanks for taking your time to read this (if you've got this far!). If you come across any problems with what i have explained reply with your question and I will do my best to answer.


Hope this helped, and happy creating!

Peace. Dreamer.
2011-08-01 19:56:00

Author:
Epicurean Dreamer
Posts: 224


Comphermc's Health System tutorial might help you with your health and energy system. It's quite simple and easy to make. Here's the link: http://www.youtube.com/user/LBPlanetorials#p/u/24/JXJzQrsGxpc2011-08-01 20:41:00

Author:
Tileno
Posts: 81


100 points equals 100% so you can use a battery set to 1% in a feedback loop system hooked up to a timer set to 0.1 second


There is no way that i know of to make a counter lose or gain more than 1 of its count in a single simulation frame

That is how classify a feedback loop system versus a counter system: FBL are great for adding or subtracting quantities while a counter system is more intuitive and straightforward to make. FBL is winning me over slowly, though.
2011-08-01 21:29:00

Author:
Antikris
Posts: 1340


Comphermc's Health System tutorial might help you with your health and energy system. It's quite simple and easy to make. Here's the link: http://www.youtube.com/user/LBPlanetorials#p/u/24/JXJzQrsGxpc

Or instead of clicking the link, just watch the video now


http://www.youtube.com/watch?v=JXJzQrsGxpc
2011-08-01 21:38:00

Author:
zzmorg82
Posts: 948


Or instead of clicking the link, just watch the video now

Lol, you stole my thunder.
2011-08-01 22:11:00

Author:
Tileno
Posts: 81


I've updated my above post, sorry it took so long to write :/ It's rather extensive.2011-08-01 23:33:00

Author:
Epicurean Dreamer
Posts: 224


O.o sad thing is. can't watch videos/go online on lbp/have fun until the 5th of this month (almost there !) epicurean... wow. just. wow. I tryed to make sense of that post but my confuzled brain is currently having problems processing the amount of text/numbers and various other stuff. D: (I'm quite stoked I got such a reply. usually my threads are like the middle of a desert. completely barren

Any way. thanks for those of you who've helped and I'll go give this all a little bit of a spin (and try for a 3rd time to de-code epic's post )
2011-08-02 05:00:00

Author:
huntedstorm
Posts: 488


O.o sad thing is. can't watch videos/go online on lbp/have fun until the 5th of this month (almost there !) epicurean... wow. just. wow. I tryed to make sense of that post but my confuzled brain is currently having problems processing the amount of text/numbers and various other stuff. D: (I'm quite stoked I got such a reply. usually my threads are like the middle of a desert. completely barren

Any way. thanks for those of you who've helped and I'll go give this all a little bit of a spin (and try for a 3rd time to de-code epic's post )

Yeah it's a big read, but it is pretty sensible, and worth the time to read. In a nut shell, the timer bar is for show, all the real calculations are done with percentage signals. The max % you can do in an instant check/change is 33% due to how the game works stuff out.
2011-08-02 05:17:00

Author:
Mr_Fusion
Posts: 1799


O.o sad thing is. can't watch videos/go online on lbp/have fun until the 5th of this month (almost there !) epicurean... wow. just. wow. I tryed to make sense of that post but my confuzled brain is currently having problems processing the amount of text/numbers and various other stuff. D: (I'm quite stoked I got such a reply. usually my threads are like the middle of a desert. completely barren

Any way. thanks for those of you who've helped and I'll go give this all a little bit of a spin (and try for a 3rd time to de-code epic's post )


If i would have been able to I'd have added pictures in where applicable, I've not been able to get onto LBP all day as my girlfriend has been catching up with her programs so I couldn't get onto the game to take pictures. When I'm able to (tomorrow) I'll go and build the system in game and take a load of pictures explaining the process and whats going on under the hood.

In my opinion its always better to understand how something is working and why it works the way it does because this gives you the knowledge to take in into other areas. "give a man a net and he can feed his family for a month, teach a man to fish and his family will be fed for a life time"

Till tomorrow...
2011-08-02 05:51:00

Author:
Epicurean Dreamer
Posts: 224


http://img836.imageshack.us/img836/2760/registerthing.jpg


A: The top input is where you plug in whatever logic triggers the skill taking 15% off your stamina, the bottom input is the same for the 20% skill.

B: this is your 15% 'value change' timer, the settings are maximum time 12,000 ~ Current time 5,400.

C: This is your 20% value change timer, the settings are maximum time of 12,000 ~ Current time 7,200.

D: This is what handles how fast your stamina refills. The different time scales i have worked out are as follows:

(All times are based on a maximum time of 12,000)
Current time ~ 20.0 seconds: Takes the Register exactly 1 minute to fill
Current time ~ 40.0 seconds: Takes the Register exactly 30 seconds to fill
Current time ~ 80.0 seconds: Takes the Register exactly 15 seconds to fill
Current time ~ 160.0 seconds: Takes the Register exactly 7.5 seconds to fill
Current time ~ 320.0 seconds: Takes the Register exactly 3.75 seconds to fill


E: This is your analogue register, settings are: Max time 0.1 seconds, current time 0.1 seconds, set to SPEED SCALE.

F: The top output is one of the two inputs on the AND gate allowing you to use your 15% skill, the bottom output is the same for the 20% skill.

Inside the sequencer are 2 batteries, set to begin at 15% signal, and 20% signal respectively, and stretched out to the end of the sequencer.

Tested in game and works perfectly.

Hope this helped clear things up for you.

peace.
2011-08-04 03:26:00

Author:
Epicurean Dreamer
Posts: 224


You can use a timer to get values less than 1%, then you can store the signal with an OR in a chip for later use (can be captured, copied etc) as long as the chip is never turned off

However, due to the inaccuracy of timers to should use a signal probe to make sure you are getting the value you want
2011-08-04 05:26: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.