Spooky Pooky #20 - Stacking Stuff

Published on 17 Mar 2015 by Joe

Apologies that this update is similar to the last but I finally got the momentum stuff working properly. Thought it was before but ... y'know, bugs and things.

The funny thing about doing physics for platformers is that you end up with a mixture of 'real' modelling (e.g. momentum, buoyancy and other force equations) and 'hacks'. In this case when something is resting on something else (like the player on a moving platform, or a block sitting on a floating block) I do what many people do and 'attach' it.

The thing doing the sitting (A) gets a handle to the thing being sat on (B). When (B) moves it artificially updates the positions of all the things (A's) sitting on it by the same amount. This avoids a whole load of niggly problems like dealing with friction and resting contacts and the like.

But it's a right old fudge, so when you then stick some 'real' physics in there you need to accommodate these things. In this case it means making sure that you when A re-collides with B next tick you only apply the momentum transfer if B wasn't already the 'ground' for A.

Fixing that then means that things sitting on other things don't generate any push downwards, so things don't sink in water from the weight of something on top. So add a little fix to make sure that force is artificially added.

TLDR; Hackety hack can stop bouncy bounce. Sad face.

Published on 17 Mar 2015 by Joe
Back to index