Home LittleBigPlanet 2 - 3 - Vita - Karting LittleBigPlanet 2 [LBP2] Tutorials
#1
Health system with feedback loops
Archive: 18 posts
Okay, I know there are some posts talking about different methods to create a health meter. I'm going to share with you the method I like the most, which isn't showed enough around here. First, here are the advantages of the systems I know well : Counter-based : easy to build, good for low hp, 100% accurate Timer-based : good for any amount of hp, works without delay (or almost), nice fluid display Feedback-based : all the good things about Timer-based, but it is more accurate because it doesn't use a timer to work You see, timers aren't precise. If you set the timer to some numbers, it sometimes last actually 1 frame less than it should be. This means 0.03333333 seconds, so that's usually not a problem. But when you use the timer as a counting device, it means the timer might not subtract or add exactly the number you input in it. (in fact it does more or less 1/3rd of the signal, but that's something else...) If you want to know more about the timer-based method, here's a video by comphermc. (http://www.youtube.com/watch?v=JXJzQrsGxpc) If you want to know more about timer error, here's the wiki. (http://wiki.lbpcentral.com/Talk:Timer) Now open this picture in a new window. (http://id.lbp.me/img/ft/8dde7386cb76f2d6aa3efd3c01becde53080b921.jpg) Now let's get an in-depth description. The red part to start, is made of a pulse (a counter wired to itself, which makes a very short 100% signal when on), a battery and a AND gate. When the pulse is activated, the AND gate will output the signal of the battery for 1 frame. The green part works the same way. Now the hard part. By connecting a combiner's output to its own positive input, it will keep the signal that was passing through it stored. Then, you can use the negative output to subtract from this stored signal. On the picture, you can see the combiner on the left with the red AND gate connected to its negative input. Next step, you must make sure not to loop a negative signal back in the combiner's positive input, because it would turn a less-than-zero amount of health into a positive amount of health. So instead of directly wiring the combiner to its own positive, we run it through a splitter, and then we connect the positive output to the positive input. Now we have a nice health system, but we can't cure yet. We need to add something to the signal before looping it back to the combiner. Addition is weird in LBP2. When there's a minus in front of parenthesis, we invert the direction of every number. So 100-(100-A-B) = 100-100+A+B = A+B. See, we performed addition by subtraction. Now NOT gates do 100-signal. So we take the positive output of the splitter, we run it through a not gate, we perform a subtraction with a combiner and we run it through another NOT gate. BE CAREFUL : combiners and splitters have an Inverted behavior, but it doesn't work. Instead of inverting by doing 100-Signal, it does 0-Signal so it exchanges the positive and the negative. That's not what we want. Now if I try to add to more than 100 it should stay 100. But the problem is that if I subtract under 0, it doesn't stop at zero. So before running the signal through the last NOT gate, we must make sure the signal is positive. If we don't, here's what happens. I want to do 90+20=100 because signals aren't over 100. I do 100-(100-90-20) = 100 - (-10) By entering the combiner, the -10 becomes 10. 100-10 = 90%. See, instead of just doing 90+20=110 and then throw the extra 10 away, it subtracted the extra 10. This is why we use a splitter before using the 2nd NOT gate. Finally, we can run the signal back to the combiner. But how can we show the health to the player ? There's a nice trick which allows us to display anything on a timer. Set the timer to speed scale. If I do Signal-Timer and feed it to the timer, what happens ? Let's say I have 50 and the timer is full. 50-100=-50 so the timer goes down at half its full speed. When it reaches 50, it does 50-50 so it stops moving. And the opposite : if the timer starts empty, it does 50-0 and goes up untill it reaches 50. Now if you set the timer to max 0.1 sec, the timer will react fast. That way, you can show any signal on a timer ! Carefull, don't use the timer's output as it will go up-down-up-down of a few digits every frame since it will never actually reach the correct value. If you want one already built because you didn't understand or feel lazy, my signature is a link to the Health Meter Toolkit, tools made with this system to build health meters with ease. There's a video tutorial inside if you like to see it step by step. EDIT: Dealing with different damage or heal values : You can copy-paste the heal or damage section of this system and use OR gates for them, then change the value of the batteries for small or strong hits. But then you encounter this problem where having two damages taken at the same time wouldn't work. Since you don't have to pulse in this method but can actually just keep the signal on longer, you could make a chip that uses a pulse to count the number of frames you have to keep it on, but seriously, who needs to be that precise ? I mean, what's the chance for you to be hit by two bullets at the same time by a .066666 second error margin ? I'll see if it's possible, but I can still teach you how to make it work with different damage types. If you use two different damage systems (or more than two), using an OR gate makes the greatest signal work. Instead, you could actually add the signals together using that add system I talked about (NOT - Subtract - Negative discard - NOT). If you're looking for me I'll be working on my combined damage of the same type... EDIT2 : Chaining multiple signals Remember that discard logic we set up to make sure we wouldn't have under 0% or over 100% ? Well here's something funny. Copy-paste the main logic (not the part that pulses the Cure or Damage). Now take the discarded signal in the subtraction of the copy, and connect it in the damage input of the original one. Then take the discarded signal in the addition of the original one and connect it to the copy's cure input. When the system 2 runs out of HP, any damage will be followed on the system 1. When there's too much health in system 1, any extra will be given to system 2. See, you just made a 200% health system! You can then use two timers and two timer overriders to display the health. And this can be extended as you wish. By the way, I though back about that way to add up projectile damages. It basically involves using tag sensors to add up the amount of damage. It's hard to explain and I don't have the game in front of me, but all my logic can be found in my Health Meter Toolkit - link in signature. | 2011-11-06 20:00:00 Author: Unknown User |
Thank you very much, it's really a nice job indeed. I have 2 questions. 1) Normally on my levels, I always put some smoke effects when the boss/enemy bar reach half of the full life bar (to demonstrate to player, is half away to destroy it), how I can achieve this if the maximum length is 0.1? I make a test putting 2 health bars, one that will represent the actual life left, and a hidden one that will represent half damage, I put 0.2 as top time for the full life, and 0.1 for the half damage, do you reckon it will do the trick? So far seem to be working... My second question is There's any way to include the %damage into the projectile itself? instead of modifying directly each battery inside the circuit board- depending on tag etc..., in few word, it's like putting the %damage (or battery at xx% in the projectile itself) I'm just trying to solve this one... But anyway thanks a lot for this tutorial was really easy to follow. Regards | 2011-11-14 17:32:00 Author: xquake Posts: 73 |
Nice tutorial, Piv! Very nice. Normally on my levels, I always put some smoke effects when the boss/enemy bar reach half of the full life bar (to demonstrate to player, is half away to destroy it), how I can achieve this if the maximum length is 0.1? Wire the output of the HP loop to a positional sequencer. Put a battery spanning the range of HP at which you want stuff to happen. Wire the battery to actions. | 2011-11-14 18:20:00 Author: Antikris Posts: 1340 |
Just replace the battery with a tag sensor set to strength. Oh do impact sensors transmit signal ? That would be great. But I doubt they do... | 2011-11-15 03:00:00 Author: Unknown User |
Hmm never checked that... If they did you could have impacts of a certian strength do damage... And I would guess people would be all over this if possible. The wiki suggests not. EDIT: a speed/impact sensor is now possible I guess, could do some interesting things with that with very little logic. | 2011-11-15 05:47:00 Author: Mr_Fusion Posts: 1799 |
Just replace the battery with a tag sensor set to strength. Oh do impact sensors transmit signal ? That would be great. But I doubt they do... I did exactly this after I published my questions... and it works... but it's not exact, because you need to set the detection radius... So will not act as the impact sensor... that detect any impact in the entire shape. Hmm never checked that... If they did you could have impacts of a certian strength do damage... And I would guess people would be all over this if possible. The wiki suggests not. EDIT: a speed/impact sensor is now possible I guess, could do some interesting things with that with very little logic. Yes you are right it's like a combination of impact sensor and the normal sensor set to signal strength I did some experimentation combining both sensors and (impact sensor to detect when something hit the shape, and the normal sensor to detect the strength set on the battery at the projectile. it works pretty well but my concern is set the radius to cover all the shape... Uhmm It will really a nice idea... Nice tutorial, Piv! Very nice. Wire the output of the HP loop to a positional sequencer. Put a battery spanning the range of HP at which you want stuff to happen. Wire the battery to actions. I will try this one too... thanks | 2011-11-15 23:53:00 Author: xquake Posts: 73 |
Mm, Mr_Fusion was talking about using SPEED sensors with impact sensors, because he thought I was talking about "do impact sensors say how hard is the impact?". The question was actually "do impact sensors transfer the signal running through the tag they impact with?". Which is, I'm 95% sure, no. But yeah, using a tag sensor and an impact sensor together works perfectly! Hey, you know what ? I really wonder what happens when a tag sensor is set to a certain number of tags and tags have % signals running through. I'll have to check that. | 2011-11-18 01:02:00 Author: Unknown User |
Mm, Mr_Fusion was talking about using SPEED sensors with impact sensors, because he thought I was talking about "do impact sensors say how hard is the impact?". The question was actually "do impact sensors transfer the signal running through the tag they impact with?". Which is, I'm 95% sure, no. But yeah, using a tag sensor and an impact sensor together works perfectly! Hey, you know what ? I really wonder what happens when a tag sensor is set to a certain number of tags and tags have % signals running through. I'll have to check that. Yes together they work perfectly I had a modified version of your circuit logic and it ran pretty well. Actually the only thing I did was I have replaced the battery from it's circuit board that get activated by the impact sensor by a sensor to detect tag strength and it wor perfectly. So I can set the actual %damage directly on the projectile and that's cool. But I also realised that in theory if more than one projectile hit the target then just one %damage will be picked up... Unless there's a way to buffer the %damage? Any way. I ended setting up 3 sensors for each type of "projectile" like : bullets, missiles and bombs. So I can rise the %damage of each type independently... Depending of the rank of the player | 2011-11-18 11:26:00 Author: xquake Posts: 73 |
Yeah, I'm trying to find a way to make multiple damages at the same time. For now, you must use multiple damage chips, but two damages can't happen on the same one. I'll find a way and post it in the next update (I already have some ideas, I'll test them later) An idea about tag sensor and impact sensor logic : place a tag on the player, place an impact sensor on the projectile, set the impact sensor to activate a tag. Make a tag sensor with a big range on the player. There's still a small problem : you have to make sure two projectiles don't hit at the same time, and you must delay the destruction on projectiles. Still, I'll find a way for multiple damage. | 2011-11-19 15:10:00 Author: Unknown User |
https://lbpcentral.lbp-hub.com/index.php?t=59607-How-to-buffer-events-(and-use-it-with-a-counter)&highlight=buffer | 2011-11-19 16:33:00 Author: evret Posts: 612 |
I've seen Evret's logic in action... I didn't really UNDERSTAND how he built it, but it does work. | 2011-11-19 21:04:00 Author: Mr_Fusion Posts: 1799 |
Thanks evret, I already saw this thing back then, but at the time I didn't fully understand it. I'll add this in and write Antikris' name on it. I've been doing my own experiment, and I found out 3 things. Using a selector and a OR gate, you can turn a pulse input into a X-frame signal by wiring the output of the selector in the next input and so on. I've made easily a system which can deal with two hits with one frame delay (so not at the same time but so close). It uses a selector just like Antikris' logic, so I were close to finding out how to do it. (btw, not sure I understand it fully, it uses 2-shots counters? I'll have to make in, but now my sister is watching loft story... yuk... and it's too late to think, my brain is off after 9pm - and my sister's too ^^). You can make a toggle with a signal combiner. All this will be in the toolkit in V3 (yeah, allready V3. I changed by .1 each time I found a bug to fix or a new chip to add. I've changed to v1 when it got released to the mass. I've changed to V2 when I've upgraded the heal system so the adder is inside the brain instead of the cure chip. Now the last thing that my logic really needed was this, so it's worth a number change. ) | 2011-11-21 02:25:00 Author: Unknown User |
AAAARG I'VE TYPED FOR 20 minutes AND IT LAGGED!!! I'll retype something simpler then... Sensors set to signal strength output the signal of the Nth strongest tag detected, where N is the set required amount of tags. If I have tags 10, 20, 30 and 40%. The sensor with required amount set to 1 will output 40, the one set to 2 will output 30, and so on, 20 and 10. By making a chain of sensors and setting them to many amounts, then adding their strength, you can add the signals of every single tag detected. Using a system where the damage pulse is set in the projectile and transmitted through tags allows to count multiple hits at the same time ! V3 of my health meter toolkit is now out, and contains this new (okay, others thought about that before me I'm sure, but still) logic, so be sure to go look at it! Link in the sig! | 2011-12-12 23:46:00 Author: Unknown User |
Sensors set to signal strength output the signal of the Nth strongest tag detected, where N is the set required amount of tags. If I have tags 10, 20, 30 and 40%. The sensor with required amount set to 1 will output 40, the one set to 2 will output 30, and so on, 20 and 10. By making a chain of sensors and setting them to many amounts, then adding their strength, you can add the signals of every single tag detected. Using a system where the damage pulse is set in the projectile and transmitted through tags allows to count multiple hits at the same time ! My friend Doner should read this. He has been building a health system but does not believe in my suggestion to transfer a gun's strength through its emitted bullets to the target. | 2011-12-13 23:40:00 Author: Antikris Posts: 1340 |
Nice tutorial. Saves a trip through rtm's logic universe for those that just need a health system | 2011-12-14 14:56:00 Author: SSTAGG1 Posts: 1136 |
Where you been man? You have not been on in forever... or maybe you have and you just deleted me. (Goes and checks PSN) | 2011-12-17 19:39:00 Author: Matt-The-Silent Posts: 52 |
Sorry, but I don't keep people in my friends list too much when I don't play with them. My list is almost full and I keep some free space for 1) people I know in real life and 2) people who need to join me for help. Perhaps I added you but deleted you, idk. Also, I haven't played LBP for quite a long time, even if I came here often. You see, I lost my soul to Minecraft. But no worries, I came back to LBP2 so I could - with the help of fly_4_a_jedi - build the V5 of my health meter toolkit, and at the same time add a section to this tutorial. | 2012-02-18 04:19:00 Author: Unknown User |
Sorry, but I don't keep people in my friends list too much when I don't play with them. My list is almost full and I keep some free space for 1) people I know in real life and 2) people who need to join me for help. Perhaps I added you but deleted you, idk. Also, I haven't played LBP for quite a long time, even if I came here often. You see, I lost my soul to Minecraft. But no worries, I came back to LBP2 so I could - with the help of fly_4_a_jedi - build the V5 of my health meter toolkit, and at the same time add a section to this tutorial. I'm the same too, its not the fact I don't like them but more of the small friends list limit. So I delete players that I don't interact with anymore. | 2012-02-19 05:11:00 Author: Chaos_Martin Posts: 298 |
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.
Die Nutzung dieser Webseite erfolgt ohne Speicherung personenbezogener Daten. Es werden keinerlei Cookies, Logs, 3rd-Party-Plugins etc. verwendet.