About
BufferModule is a system built to help combat input latency when using physics on Roblox. This system is built using the principles described by TheNexusAvenger in this article on his website.
Why is this Important?
A delay between a player firing a weapon or projectile can seriously the user experience in situations where the connection isn’t optimal (which is surprisingly often!). Lag creates a disconnect between the player’s input and what they see happen on screen.
Furthermore, lag can cause players to miss their targets unfairly when firing weapons. Players should not have to compensate for their ping when playing a game.
Why use this implementation?
- Support for multiple items inside of the Buffer
- Security features that help protect against abuse of the system
How does this work?
This module creates a Folder that stores all items added to the Buffer via the server, such as projectiles. When an item is added to the buffer it will have its NetworkOwnership assigned to whichever player is given ownership over the buffer (e.g the player who is holding a weapon).
Buffered items are held suspended far away from the play area. When the client needs to create a new projectile, such as when the player activates a weapon, instead of creating a new Instance we instead pull an existing one from the Buffer. Since the Instance already exists and we have NetworkOwnership over it, we can instantly start controlling the physics of the item.
On GitHub, the repository contains an example place with some tools you can test for yourself. Attached below are videos that demonstrate the difference in input latency with 400ms ping. Pay close attention to the firing sounds and clicking indicator in the bottom right.
Before Implementation
After Implementation
The first video sees the player suffer from serious input lag due to their high ping. However, in the second video, this is completely solved. Great!
The system has uses other than weapons too, such as this tool that spawns blocks. The black outline represents before the request to place a block has been received by the server. For this example, 10 blocks are held in the buffer:
Block Spawner Example
Caveats
As nice as the system sounds, it does come with some clear caveats that may influence if you decide to use this system over something else:
- This method is not supported natively by the Roblox Engine. This comes with some weird downsides, such as how buffered items need to be stored as descendants of the Workspace, or how buffered items cannot be Anchored until they are removed from the buffer.
- The client has control over the physics of items in the buffer. This comes with the usual security concerns of giving the client NetworkOwnership over parts.
Installation & documentation
Installation and documentation are both handled through GitHub.
Installation Guide • View documentation • GitHub Repository
Final Note
Questions, suggestions or bugs? You can open an issue on the GitHub repo - or alternatively, let me know in this thread or message me privately. Thanks!