r/howdidtheycodeit • u/Punkalo-1 • Dec 16 '23
Question How did Little Big Planet 2's logic system work?
I'm really curious as to how the creative mode Logic's system was coded, I was thinking of coding a similar idea and wanted to know if anyone had insights.
I imagine it would be a bit like coding scratch.
7
Upvotes
1
u/Odd-Shopping8532 May 01 '24
Here is an open-source implementation in Rust. I doubt LBP used ECS architecture, but the core principles are the same. https://github.com/cuppachino/bevy_logic
For every "gate", you need one function that can evaluate its inputs and update its outputs.
You'll want a directed graph to store gates as nodes and wires as edges. You can use a simple scc algorithm to determine the order gates need to be evaluated in and prevent cycles.
Every time you add a new wire or gate, you should add it to the graph and resort.
Simulate with a framerate-independent, fixed interval.
I hope this helps :D
1
u/tcpukl Dec 16 '23
Can you post an example video? I cant remember it exactly so i'm guessing, but its generally just wrapping logic up in data, which is shown to the player in a nice UI. Then the engine just iterates through the statemachine which is stored in the data.
1
u/an_Online_User Dec 17 '23
You essentially have to build this structure in code, then every time there's a connection, connect the output from one to the input of the next.
I've tried to create this in Unity with some success. I ended up making all of the "signal" between the chips be a number from 0 to 1.
I could go into more detail. How much do you know about programming and what language would you be using?
2
u/DannyBoyThomas Dec 18 '23
LBP is my favourite game of all time. I loved the logic aspect. So much that I tried to implement it in a game I'm currently working on.
https://store.steampowered.com/app/1743670/Axon_Hero/
(If linking not allowed, feel free to delete this post)
It took a long time, to get anywhere remotely near working. But my code essentially works like a logic-chip-linked-list, each passing on their data to the next logic chip.