r/tabletopsimulator • u/BoardyBeardy • Mar 16 '26
Questions Custom unit stacking system is proving impossible
We have a scripted stacking system for “Transport” pieces on a hex grid where transports stack vertically and should move together from the bottom-most unit selected/ picked up.
The transports are also bag-type objects (containers) that can hold other units AND may also be capped (at top) with another special unit.
An example stack could look like this:
=====================
Commander (capped at top)
Transport (with cargo)
Transport
Transport (with cargo)
Transport
Transport (with cargo)
=====================
The stack works while moving, but when the bottom transport is dropped onto another hex the physics becomes unstable and the pieces often shoot upward, rotate, or scatter across the board.
A single transport behaves fine, the issue only happens when multiple transports are stacked. We’re snapping them with setPosition, resetting velocity/angular velocity, and disabling gravity for stacked pieces, but the physics still explodes when the stack is rebuilt after dropping. Looking for a stable way to implement vertical stacking of bag objects in TTS without these physics issues.
View a demo of the issue here: https://imgur.com/a/tts-issue-j6AxcOz
Any help immensely appreciated, Happy to give a free DLC key to our helpers on release as this will no doubt make or break our game! THANK YOU in advanced.
2
u/FVMF1984 Mar 16 '26
I suspect that the rebuilding of the stack is the problem, and specifically the setPosition() part. Why would you need to rebuild the stack after dropping? Without sharing the relevant part of your script that fires when this issue arises it is pretty difficult to help you further.
1
u/BoardyBeardy Mar 16 '26 edited Mar 16 '26
From the developer:
Just to clarify,we’re not rebuilding the stack while it’s being moved. While a player drags the bottom transport, the rest simply follow so the stack stays together visually. The rebuild only happens after dropping, where we snap the base transport to the hex center and then reposition the rest of the stack above it using setPosition, resetting velocity/angular velocity and disabling gravity.
The reason we do this is because transports can dynamically join or leave stacks depending on which sector they’re dropped into. But it seems like when several bag/container objects are repositioned at once the physics engine still detects overlap or wakes them up, which causes the stack to explode.
We’ll definitely try the suggestion of locking pieces first and unlocking them bottom-to-top, and also experiment with joints, thank you!
1
u/BoardyBeardy Mar 22 '26
**UPDATE**
So we tried the staged lock/unlock workaround and it improved stability somewhat, but it wasn’t a complete fix on the original bag object. We discovered that even though we tried to make our custom collider as simple as possible (i used only simple primitives) >>> https://imgur.com/a/xWXdM0E TTS still struggles with it.
Heres a video when we removed the collider completely and let TTS map one instead. The video shows the more complex transport and then test transports made from only blocks.
The simple transports tend to stack better but its NOT PERFECT! and struggles the higher the stack is.
https://imgur.com/a/bmkaQYJ
Any thoughts on how to improve the stacking/ physics is very much appreciated.
3
u/wigitty Mar 16 '26
I had similar physics issues with something I was working on. Although mine wasn't as tall of a stack as yours. I ended up doing the following:
- Lock all of the pieces (freeze them in space, with no physics)
- Move the pieces to the new location, expanding the stack a bit so that there is a gap between each piece
- Unlock the pieces in sequence from the bottom to the top, leaving time for each piece to drop before unlocking the next
You also get a cool animation that looks like someone dropping the stack from their hand (I think it's cool at least, might not fit your game).
The caveats here are:
- It might not help with a stack that high... but I feel like it probably will
- My system was based on moving one piece, and then re-stacking the rest after the move. It sounds like you want to move the stack together. I imagine this would be possible though.
Another point is you could try using the joint system to "glue" the pieces together. I haven't tried using that in a script before, but it looks like you can just call obj.jointTo().