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

Need Help With Randomiser Logic

Archive: 8 posts


I'm usually good with logic and I'm sure this has a simple solution but somehow I can't figure it out.

I have a sackbot that can attack and when he attacks I want to emit a small slash in front of him. However, to avoid this becoming repetitive, I have used a randomiser and four different slashes so that each time you attack a random slash will appear:

http://i7.lbp.me/img/ft/087ea6db882138c5e44a528558e36d44941e9480.jpg

The input is on when the player attacks, the randomiser is set to 'one at a time' and 'override pattern' and the emitters are set to 'one shot' and 0.2 second lifetime.

The problem I have is when the randomiser picks the same slash multiple times in a row. Because that input will already be active, it will not trigger the one shot emitter again, so no slash will be emitted. I can't figure out a way so that even if the randomiser picks the same emitter twice, the slash will still be emitted again.

All I can think of is using OR gates with large numbers of inputs to lower the probability of the randomiser picking the same output twice. However, this would be very messy and wouldn't completely fix the problem.

Any ideas?
2012-06-19 13:19:00

Author:
PGdafrog
Posts: 277


i dont have time to explain this fully, but it's pretty straight forward if you look at the pic and recreate it. all you need to know is the randomizer and emitters are set the same as you already have them, and the 4 counters are set to 1 and wired to their own reset.
it will activate an emitter when the input is activated, then it will select a different slot ready for the next activation.
the only time it may pick the same one twice is if the input is activated again within a few frames of it being released
http://i0.lbp.me/img/ft/bb09938e536b783c691da82e34dd4bc2f7dbd2c2.jpg
2012-06-19 15:33:00

Author:
evret
Posts: 612


Thanks so much! I get how it works but that probably would have taken me a while to figure out by myself. I can't test it out 'till tomorrow but I don't see why it wouldn't work.

EDIT: Finally got round to testing it. It worked. I'll change the thread title so it says solved.

ANOTHER EDIT: I can't change the thread to say it's solved. Does a mod have to do that?
2012-06-19 17:23:00

Author:
PGdafrog
Posts: 277


If anyone's still interested, I found a much cleaner way to achieve this:

http://i1.lbp.me/img/ft/af171923ad067f47eee3c34f71d2999998855c6a.jpg

The randomizer is on its own chip and the input is routed to both the randomizer on the chip and to the microchip activate input.

http://i2.lbp.me/img/ft/902e05f55e586bab2a16702faff09ae0ea39bd50.jpg

http://i5.lbp.me/img/ft/fe555369e7429b41907684c028401b3c67d03d4d.jpg

The problem with the randomizer is that it behaves like a selector in that the last active output stays active until another is triggered. This approach allows it pulse by only outputting the randomizer signal when the microchip is activated. Fairly clean solution that will work every time (or so far has for me).

Hope this helps!

this does not guarantee a different output each time.......
and there was no reason to post this in both threads
2012-07-05 06:51:00

Author:
evret
Posts: 612


Yeah - I should have just posted a link in one or the other thread. My bad.

I realize it doesn't prevent the same item emitting twice - my understanding of both questions was how to prevent the lapse when it selects the same node twice in a row (a problem that I personally hate with the randomizers). Just offering another approach to that problem. Your solution does both and is quite elegant - I meant no disrespect.


EDIT: Deleted my prior post. evret was absolutley correct to say that it did not need to be repeated in two threads. I have a solution for at least part of the problem here: different help thread (https://lbpcentral.lbp-hub.com/index.php?t=71905-Different-randomizer-output-every-time&p=1021262&viewfull=1#post1021262)
2012-07-05 07:36:00

Author:
v0rtex
Posts: 1878


and there was no reason to post this in both threads

Yes there was! I wouldn't have noticed the new method if you hadn't posted it in my thread
2012-07-06 19:28:00

Author:
PGdafrog
Posts: 277


so u didnt think to look at the thread that had a similar title to yours? also u stated you wanted a different output every time so his "new method" doesnt suit your needs.
also his method adds a frame of latency as it uses the activate input of the microchip. a better solution would be to add an extra input to the selector, wire a NOT gate to the extra input, then wire your input wire to both the randomizer and the NOT gate.
2012-07-07 06:27:00

Author:
evret
Posts: 612


also his method adds a frame of latency as it uses the activate input of the microchip. a better solution would be to add an extra input to the selector, wire a NOT gate to the extra input, then wire your input wire to both the randomizer and the NOT gate.
That's a really good idea. And I didn't realize that using the activate input adds a frame of latency. Thanks for that!
2012-07-08 07:07:00

Author:
v0rtex
Posts: 1878


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.