Home    LittleBigPlanet 2 - 3 - Vita - Karting    LittleBigPlanet Vita    [LBPV] Tutorials
#1

Feedback loops and health meter

Archive: 10 posts


There are many new possibilities now in LBPVita allowing us to make health meters with ease. First of all, the analog values are now accurate (1+1+1+1+1+1+1+1+1+1 will equal 10 perfectly), which was not the case in LBP2 (for reasons I won't explain here). Here's how to make health systems in LBPV.

Before we start, I'll remind you how signals work in LBP2 and Vita. Two types of signal are transmitted through wires: analog and digital. Those two types are sent both by the same wire, at the same time, and may be opposite. The digital value is either "ON", "OFF" or "Backwards" (usually written 1, 0 and -1). The analog value can be from -1 to 1, including fractions (usually written in % value).

The OR gate now has a new option: input addition. This mode will allow you to add signals together. Also, it takes negative signals into consideration, so 30% +OR -40% = -10%. If you connect the OR gate's output to it's top input, the signal will be stored in a loop.

Let's create a pulser: Put down a counter, set its maximum value to 1 and connect its output to its own reset. If you power the counter, it will turn ON, sending a signal to the reset, immediately turning the counter OFF. It takes one "tick" for the counter to be reset. A tick is the smallest time unit in a system, it's the amount of time it takes to update the state of wires and gadgets.

Now take a look at the AND gate. The regular AND gate will output the smallest value it receives. If you connect a 5% battery to an input of a 2-inputs gate, it will output nothing, because there is 0% received in the other input, which is smaller than 5%. But if you make a 100% signal come in the second input for one tick only, the AND gate will output 5%, for one tick. That is how you can make an analog pulser by combining a counter, a battery and an AND gate. Now I said the AND gate took the smallest value, but if you connect 5% and -10% to it, it will output -10%. It actually takes the signal further away from 0%.

Also, the AND gate multiplies the signals to tell the direction of the output. If you feed it -5% and -10%, it will ouput +10%. Knowing this is great, because since the digital value of the full counter is +1, the AND gate will output the sign of the battery. Note that the regular OR gate, set to keep the greatest value, will have the sign of the strongest signal. If you connect two opposite signals (such as 100% and -100%), the gate will take the sign of the first input. Note that this happens with the OR gate set to the greatest value, and in this system we will set the OR gate to add signals, which will not behave like that.

Finally we'll talk about the health system Let's make it a step by step guide, I'll explain after so I don't get carried away.

Place an OR gate and set it to add inputs.
Since the health should never be negative, connect the OR gate to a direction splitter, and then loop the positive output back into the OR gate's first input to keep the positive part stored. If you want to use this for another purpose than health and need negative values, just connect the OR gate to itself directly.
Make an analog pulser: place down a battery and connect it to the first input of an AND gate. Place down a counter set to maximum 1. Connect its output to itself, and to the AND gate's other input. Place this analog pulser on a microchip, as you will need multiple copies of it.
Set the battery inside the analog pulser to the value you would like to take away from the player when he is hit by a small projectile. I want my player to have 4 lives, so I'll make him lose 25% by setting the battery to MINUS 25%.
If you want the player to lose more health when he is hurt by, let's say, a big projectile, copy-paste the microchip and set the second microchip's battery at another value. In my system, my bigger damage will be 50%.
You probably need an instant-kill chip for when the player falls in gaps. The instant kill can be a chip with a -100% battery.
Now to heal the player, repeat the process using positive values for the batteries. I'll make a 25% health pack and a 100% health pack.
To heal the player by 100%, just use a pulser, no need of an AND gate and a battery!
You can keep on copying these chips until you have one for each type of projectile damage and health packs. Then, connect all their outputs to the OR gate. Just give the OR gate more inputs in its tweak menu.


See how this works? When you will send a signal to the counters inside the chips, it will add or subtract the value from the current health stored in the OR loop. Now we might want to display that signal, right? There are multiple ways to do so.

First, you can use a note. Place down a note and go to the bottom of its teak menu. You can change the input action to signal strength, making it display the input. Then you could replace the % logo with " HP" for health points (notice that there is a space before HP, it looks better). You can also set it to a custom maximum amount. I wanted to give the player 4 points maximum, well we can touch the number to display the keyboard and type 4. You can also make a 10000 display if you want! You can make the text visible in play mode but the note background itself invisible.

You can also use a timer. There's a new position mode on timers which will turn the timer into a value display. The programmers really looked at out needs with this game You can set the timer's maximum to 0 seconds, making it an instantaneous display, or set it to something higher like 0,5 seconds to make smoother transitions. You can then customize the color and make the timer visible in play mode.

What about custom HUDs? You can place down a sequencer and set it to position mode. Then you can put batteries of different lengths on it. Which batteries are ON will be based on the amount of health you have. You can wire the batteries to sticker panels and create a custom HUD.

About the 10000 health points... If you make a note display 10 000 points max, then 1% will make you gain 100 points. You might want to deal smaller amounts of damage at once. The AND gate has a "multiply" input mode, and you could use this to get 1% of a percent. Connect two 1% signals to it, and the multiplied outcome will be 0.01 * 0.01 = 0.0001, or 0.01%. Once you have the value you want, wire it to an or gate and wire the gate to itself to store it in a loop. Now to use these values in the health system, just replace the batteries in the analog pulsers with these stored signal. Note that when the chip it is on is powered off (bottom input of a chip), the loops will lose their memory. You can prevent this by putting them on sequencers with 0 radius.

Evret's idea
While using negative and positive batteries is simple, it isn't quite visual. Unless you go and change the color of your batteries, it won't be easy to know what heals and what hurts by looking at your system. Evret suggested a nice alternative in post #8.

That's it! The rest is up to you. If you would like to make that kind of stuff on LBP2, there's a link in my signature to a toolkit, because it's way harder to do the same on the PS3. The toolkit is old and not perfect, but I sadly lost everything a couple years ago when my console died and never had the motivation to rebuilt everything. Note that this logic can be used for currency system, mana gauges and way more.

If you need to see pictures, try the vita level! Link in signature under the picture.
2012-09-28 03:05:00

Author:
Unknown User


personally i prefer using 2 adding NORs to form the loop. the first one is for adding to the loop, the second for subtracting. this way you dont need negative signals (all signals are positive by default) therefore removing the need for the splitter to dump negative (there will never b any).
this way you can save on batteries by using the same for both adding and subtracting if the same value, and its a lot easier to keeps track of which is for adding and which is subtracting. having both on the same OR will get annoying when adding to more inputs for both if you want to keep them together.

also a better way to get those smaller values is to connect batteries to both inputs of a multiplying AND gate. for example 1% X 1% = 0.01%. then you could multiply that by 1% to get 0.0001% etc.
you should also consider using a memoriser to store the smaller values, while they may use more thermo than an OR or a node they wont lose the stored value if the chip they are in is deactivated
2012-09-28 08:27:00

Author:
evret
Posts: 612


Nice one, using two NORs is good, but I prefer my setup because it's easier to explain to people than the 100-((100-a)-b) = 100-100+a+b idea. I'll try using your idea, and perhaps I'll find it more practical over time, but I'm used to having all the wires going in the same chip. Oh well, I'll quote you in the first post then

About the small signals - you might not have read it, but I do say that you can make a percent of a percent using AND gates. I guess I can just remove the mover setup, I only thought about the AND gate afterward and then added.

You could place the node loop on a sequencer, and it won't ever be off
2012-09-28 17:53:00

Author:
Unknown User


You could place the node loop on a sequencer, and it won't ever be off

Clever! Good thing we didn't fix that.
2012-09-28 18:40:00

Author:
comphermc
Posts: 5338


Ohai there!
I just published a level with this tutorial. Link should pop in my signature soon.
2012-09-29 03:00:00

Author:
Unknown User


Ah, I just published something pretty similar to this as well, mine's just a chip that inputs for damage, restoring health, timed damage, timed restoring, resitance, and such.
http://vita.lbp.me/v/9xez9

Anyway, I'll be trying yours as well, looking forward to that.
2012-10-13 19:52:00

Author:
ChrisF2112
Posts: 265


I would have never realized you could save the values from resetting by sticking them inside sequencers. Thanks.2012-10-14 06:44:00

Author:
SSTAGG1
Posts: 1136


i started having issues with the adding NOR setup when it came to copy/pasting and turning chips on and off. sometimes the wrong NOR would start off outputing 100% and messed things up so i've started using this setup, still with all positive signals (batteries etc).
the adding ORs at the start are only needed if there is more than 1 adder/subtracter and can have as many ports as needed.

http://i4.api.vita.lbp.me/img/ft/d04001ccad1b3ee825b2c5998dbea9329b4fea58.jpg
2012-10-14 14:28:00

Author:
evret
Posts: 612


Thanks for this tutorial it has helped me out heaps already. I have managed to make a full health and ammo system and even a currency system with this.2012-10-16 22:45:00

Author:
Lordwarblade
Posts: 761


Glad to see that pivottt's (and friends&apos health counter efforts have made the vita jump!

I had a weird experience one day where a standard OR gate with equal magnitude, opposite signed input signals (like +10% and -10%) could not be relied upon to always give the sign of the first input. Sometimes positive, sometimes negative. I had a pretty trivial example set up to verify, with two batteries for input and a note for output, and if I just rotated the cardboard block my chip was on, the output signal would sometimes change signs. At the time it happened so consistently I assumed it would be easy to reproduce the bug, but I tried just now in an empty level and only got the proper behavior (always sign of input #1). I had a LOT of logic running in the earlier level (many copies of many elaborate chips) so I don't know if that had anything to do with it.

Anyway, I don't want to derail this thread, but I thought I'd mention it in response to Pivottt's opening tutorial on how these gates are supposed to work. (and because I figure if anybody else is likely to hit this bug, it's the people following this thread!) If somebody else could verify I'm not making all this up, I'll go post it on Get Satisfaction.
2012-10-17 00:56:00

Author:
LittleBigDave
Posts: 324


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.