Bouncepad
Boing boing boing…
Why getting a mod to fly in the air, when you can BOUNCE in the air!? (don’t worry you can do both :p) And not only can you bounce yourself, but you can also play ping-pong with any moving object on the map!
Demo video by Tearspot
TOOLS
– Bouncepad: Let you place different types of Pads.
KEYBOARD CONTROLS
– [T]: Change Pad type.
– [LeftClick]: Place a Pad.
– [MiddleClick]: Replace closest Pad.
– [L]: Remove closest Pad.
– [K]: Remove all Pads.
– [Ctrl]: Hold to make Pads ignore you.
– [RightClick]: Hold to move Pad preview in front of you.
– [RightClick]+[Scroll]: Move Pad preview closer/further.
– [RightClick]+[X]+[Scroll]: Rotate Pad preview pitch.
– [RightClick]+[C]+[Scroll]: Rotate Pad preview roll.
– [RightClick]+[V]+[Scroll]: Rotate Pad preview yaw.
– [RightClick]+[MiddleClick]: Reinitialize Pad preview.
– [RightClick]+[Ctrl]: Hold to increase move precision.
– [O]: Open options menu.
CHARACTERISTICS
– Pads will bounce any moving object or player, regardless of their size or mass.
– Pads will bounce on both sides.
– Pads will only bounce physical objects (not bullets or lasers).
– Pads are unbreakable (immune to explosions, lasers, weapons, etc.).
– If an object moves too slow, Pads will ignore it to avoid flickering.
– Values changed in the options only apply to future Pads, not existing ones.
– Each pad type bounce objects differently:
— Trampoline: Objects bounce naturally, keeping their momentum.
— Bouncepad: Objects bounce straight, keeping their momentum.
— Jumppad: Objects bounce straight, always with the same force (editable in the options).
— Antipad: Objects bounce back, keeping their momentum.
KNOWN BUGS
– Pads may bounce an object before it seem to actually touch the Pad.
– Pads may fail to detect objects with a really high speed.
– Objects or players being bounced really fast may glitch through other objects or through the map (use the Emergency Respawn button in the options if that happen).
– Pads may appear to be in front of other Pads when they are actually behind.
– Pad bounce effect (wireframe square) may appear in front of other pads when it’s actually behind.
DEV NOTES
The core idea for this mod was to make Trampolines, as in spawning actual (physical) trampolines in the world that objecs and player would bounce on. While the idea could in theory work using the same method as the Top Spinners does, I was not sure if I could make objects bounce efficiently as if the objects to bounce did collide with the trampoline object, they would probably lose all speed :/
Which is why I took a different approach, getting inspiration from the Grasshopper (World Trigger) to make some non-physical bouncepads that would be less likely to fail a bouncing correctly ^^ In order to build those visually I got inspired by the Voxel Spawner weapon which used sprites to diplay fake voxels (cubes).
Then came the first hard part of letting the user freely move and rotate the Pad preview around him. This was mostly vector math with a lot of help from the pre-build function in the modding API as well as some extra utility functions from the Gas Can mod. This part ended up to be okay even if the rotation method could be a little better (rotating from the player perspective instead of rotating from object center).
After this part was complete, I was able to spawn Pads in the world, so I could start working on the second hard part: collision detection. As I am not using a physical object for the Pad, I can’t make use of the built-in collision detection of the game. So I had to make may own "object to square" collision finder. Once again a lot of vector math involved here, as well as some approximations on the object shape to avoid having too much resource intensive calculations while still having bounce visually happen when they should.
Once this was over, the mod was pretty much done, the bounce calculation itself (all 4 types) is pretty easy compared to all the collision stuff. And after playing around with it a little, I noticed that building some structures with perfectly aligned Pads would be quite hard with the initial system… So I added a grid option to be able to have perfectly aligned Pads ^^