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

Help with logic to select two of three states at a time.

Archive: 12 posts


So I've got three different enemy bots that spawn into the level I'm working on, but as it turns out, fighting three guys at once is a bit overwhelming for a single player so I want to rig it so only two spawn at a time. There are a number of conditions that need to be true for any of them to spawn already (two players or less, and no copies of the bot already in the level), but I'm trying to rig it so that the three bots are on a cycle so only two show up at once. So when bot one and two are present, bot three won't spawn. If bot one dies, then he goes back to the end of the line and waits for bot two or three to die. But I can't figure it out! Any ideas on how to do this? I'm sure it's not that complicated, but I can't figure it out for the life of me.2011-02-17 21:43:00

Author:
Sehven
Posts: 2188


could you tag the bots and set a tag sensor to require two with an inverted output? That way everything would run until two bots are out, then pause until one dies.

Not sure how you would recognize which one died and adjust the queueing.
2011-02-17 21:46:00

Author:
tdarb
Posts: 689


Could you set up two staggered (output) selectors and an OR gate with corresponding inputs from each selector? I may be under standing this wrong.2011-02-17 21:47:00

Author:
piggabling
Posts: 2979


I've already got a detector that disables their spawners when two are present, but the problem is they all spawn at the same time, so whenever there's 0 all three will spawn and when there's 1, the other 2 will. If there are 2, the third won't spawn, but as soon as it goes down to 1, the other 2 spawn again. What I need is the logic to disable the emitter of whoever was spawned the most recently while leaving the other two enabled.

@ piggabling, sorry, but I'm not sure what you mean. One selector feeding into another? How would that work exactly?

[edit] I've got an almost working system. I put timers on each of the bot's detectors so that it won't flag them as missing until .5s after they die. That way they're not waiting to spawn yet, and by the time their timer fills up, the other guy will have spawned and they'll have to wait for the next opening. It's not perfect, though: if I manage to kill both guys in rapid succession, there's a chance they'll both spawn after the third guy: it only happened once during my testing, but I'd rather eliminate the possibility entirely.
2011-02-17 21:53:00

Author:
Sehven
Posts: 2188


could you set them all to different time offsets?

Otherwise, maybe toggle switches?

Have a toggle on each emitter, and set two to on, and one off.

When an emitted object "dies", it flips the state of its toggle to off. It also tests the other two toggles and flips the one that is OFF to ON, and makes that one emit your next bot.

It may need a small delay in emitting just to ensure the toggles flip quickly enough, but it sounds like it would work.
2011-02-17 22:05:00

Author:
tdarb
Posts: 689


Set up a selector with four ports. Don't hook the first port up to anything. Each of the other three ports are activated by a tag sensor that corresponds to each of the three bots. The active port will always be the last one to spawn in (if they actually spawn in on the exact same clock tick, it's pot luck which port it will select but I'd guess it will be port 2. You can then disable his emitter, so the other two remain active. You can also reset the whole thing by selecting port 1. This solves your direct question, but won't you need additional logic for when they die off?2011-02-17 22:18:00

Author:
Shanghaidilly
Posts: 153


I've already got a detector that disables their spawners when two are present, but the problem is they all spawn at the same time, so whenever there's 0 all three will spawn and when there's 1, the other 2 will.

I had a similar problem spawning asteroids. I ended up changing my emitters to timed rather than one-shot, and just having a different sync setting for each one to ensure they can never emit at the same time, so when the system detects there should be more asteroids, it enables all the emitters, but as soon as one triggers, it disables all the others.
2011-02-18 11:48:00

Author:
Aya042
Posts: 2870


Why not just invert selector with tree states? That way only one state can be inactive and others are active.2011-02-18 12:05:00

Author:
waD_Delma
Posts: 282


I've tinkered with that, but I'm not sure how to finish the logic after I set the inverted selector. I suppose the most recent bot to emit should trigger his own port on the selector, thereby disabling his emitter. Hm. Coupled with the two bot limiter, that might be all I need: as long as bot 1 is in the play area, his emitter is disabled, regardless of what happens with the other two bots, but once he dies, his emitter would immediately enable... unless I stick a timer between the selector and the emitter. That seems like it should work and it should even solve the problem of having all three spawn at the beginning. I'll give it a try tomorrow and report back if it works.2011-02-18 12:41:00

Author:
Sehven
Posts: 2188


http://i6.lbp.me/img/ft/966f9723d9270fdc49f0ab76e8eb5c6fed362f7b.jpg
This works. Tag sensors to the left are inverted and connected to timers with 0.5 delay(you said your thing is dead after 0.5) and start count up. Yellow tag sensor requires 2 and inverted, emitters are oneshot, microchip contains circuit nodes.
2011-02-18 12:45:00

Author:
darkphoenix
Posts: 97


Arg! None of it is working! Selectors are problematic because an active signal to any port prevents any others from becoming active. I can't do the emitter timing thing, 'cuz I've actually got four emitters per bot hooked to a randomizer (that would screw up the timing, right?) Everything I try either leaves me with only two bots spawning for the whole game or with all three at once and sometimes even duplicates of the same one (one vanished right in front of me 'cuz another had been fired from the same emitter).

[edit] I spoke too soon on the timing thing. Turns out all I had to do was change the randomizer settings to a min/max of .1s on and .1s off to eliminate the possibility of two firing at once. That's got me to where it seems that I'm only getting one of each bot and only two at a time, but the two that I get seem random rather than sequential. That might not be such a bad thing, though and I doubt it would be seen as a negative in my level by anybody but me, so I'll tinker a bit more but if I can't de-randomize it, I'll be ok with that.
2011-02-18 21:03:00

Author:
Sehven
Posts: 2188


No, not a selector to a selector. Two separate selectors with their outputs staggered. Selector one would activate output 1while selector two would be activating output 2 at the same time. Then, connect each corresponding selector out put -- in your case 1,2, and 3 -- to OR gates. Here, maybe this will help:


Selector One; Output 1 |----------OR Gate 1
Selector One; Output 2 |---------------OR Gate 2
Selector One; Output 3 |--------------------OR Gate 3

Selector Two; Output 1 |----------OR Gate 1
Selector Two; Output 2 |---------------OR Gate 2
Selector Two; Output 3 |--------------------Or Gate 3

Selector One; Output 1 **ACTIVE**
Selector Two: Output 2 **ACTIVE**

Then, attach your each of your three OR gates to the desired outputs. You might have to make sure each selector is triggered at the same time, but maybe not. I'm having trouble visualizing that part.

EDIT: Okay, maybe you have it now. Still, there it is if you need it.

Quick Question: Can Tag Sensors get activated by a Tag on the same microchip now?
2011-02-18 22:30:00

Author:
piggabling
Posts: 2979


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.