Freya Holmér
Freya Holmér

@FreyaHolmer

14 Tweets Dec 15, 2022
does anyone have any good resources on like, uh, the structure of (very) basic physics engine loops?
specifically like, order of operations, when/how to apply forces/velocity/friction etc.
thinking about my puzzle game, it might be a better approach than my current one (thread)
here's my current approach
when an object is pushed/affected by a force, it recursively tries to apply the action to the objects ahead, returning true/false for whether or not it can move, then does the same for things on its head (assuming friction allows for it)
this works! (mostly)
but it feels very, hardcoded, and I'll have to keep adding exception after exception. and the way it handles frictionless objects is, messy as heck
I'm also struggling to put up a nice, flow, for detecting and executing separate sets of physics actions, ie, I don't have a SimulatePhysics() function, it's all, calculate the final position things will be in, then check if anything needs to fall, and that's it
and just to be clear - I'm not looking for collision detection/collider intersection tests!
that's the easy part of what I'm doing, since it's all grid based
I'm talking suuuuper basic here, like a little flowchart of just what force to apply when and in what order, but slightly more detailed than this
I might just have to work it out myself though, since I probably have some weird exceptions wrt things like falling
I appreciate it but yall are linking *way* too complex things, haha
I'm sitting here with a bucket trying to build a sand castle, trying to figure out whether to put the sand in the bucket before or after plopping it upside down
my use case is super simple, I literally just need to resolve forces and whatnot for completely grid based movement
units can't be between grid units, they're always on grid (visual animation aside), so movement is discrete, no linear algebra/integration needed
I guess the fact that it's discrete makes it so that I need a custom loop/force resolution flow anyway, I'll see what I can figure out. I also need to define my problem space a little better
I regret using the phrase "physics engine" and most people don't read the full thread so rip me 😔
idk what else to call it ;-;
if I call it a cellular automation then people will link videos about slime mold and conways game of life
okay sketched out a test case to see how I imagine it would work
I think I can make out three separate operations
🟣 force/velocity propagation
🔴 friction/gravity gathering
🟡 movement
for context:
🟥 normal box (mass = 1)
🟦 frictionless box (mass = 1)
🟩 light box (mass = 0)
this seems like it should be so simple, I feel stupid for taking so long to wrap my head around this ;-;

Loading suggestions...