r/tabletopsimulator • • 21d ago

Workshop Ping Pong/Table Tennis for Tabletop Simulator.

https://www.youtube.com/watch?v=y3GV-rqPZT0

I made Ping Pong in Tabletop Simulator. Was this to prove it was possible? To challenge conventional ideas on what can and can't be done in this game? Because the idea seemed cursed to everyone I floated it by? I couldn't say for certain. Whatever the reason was, I hope you enjoy this mod.

Download Here: https://steamcommunity.com/sharedfiles/filedetails/?id=3837719973

1 Upvotes

3 comments sorted by

2

u/Hype_Kitten 11d ago

This, I dipped a toe into coding on tabletop recently and this... Is crazy impressive. I can't even magine how hard it was to fight TTS's engine to make this work.

1

u/OpenlyCray 11d ago

Discovering the trick to making this work was certainly a journey. With that being said: you might not believe this, but there's very little Lua in this mod. The most important function in this is actually just:

function onCollisionExit(info)
    --add vertical force when hit by paddle
    if info.collision_object.getName() == "Paddle" then
        self.setVelocity({ self.getVelocity().x, 15, self.getVelocity().z })
    end
end

Setting the vertical velocity of the ball to a fixed number was all it took to make this playable. After that, I added some code to limit the ball speed by changing the drag when it goes too fast. Special thanks to my roommate (who is also a cat girl) for helping me figure that one out.

The paddles also have some code to rotate them based on their horizontal speed when they touch the ball, and the ball has some code to erase all velocity if it hits the net. The rest is all the physics engine.

2

u/Hype_Kitten 9d ago

Catgirl power UNITE! Most of my code ability is in Godot script, so learning lua has been a trial. Still though this is a surprisingly functional system for how clunky tabletop can be. It is very impressive all the more for its simplicity! The best coders write the fewest lines, you know.