SecureCast, server-authoritative projectiles with lag compensation, multi-threading and more!

as far as I know you cannot really account for the roblox buffer that they add for interpolation unfortunately, as no one knows exactly how it works.

However someone could just replicate positions via remote events to the servers and it would still work, even better if anyone has any custom character controllers that rely on the custom replication behavior they could easily fork your resource to get server sided hitboxes

So this resource is still a W

Calling workspace:GetServerTimeNow() actually accounts for this buffer and works as a precise synced clock between the server and client

Using GetServerTimeNow() only accounts for a players one way trip latency, the interpolation buffer is separate from the players latency and is applied between position packets, the best estimate which I’ve come across for this buffer is a range from 80-100 ms.

1 Like

Lag compensation is something I am really interested about. Cool to see someone actually try to implement it

I think it’s best for you to decide, I don’t know your game structure and would be biased towards my own resource.

2 Likes

Off topic, I just saw that you uploaded this resource: Performant skinned mesh ocean with built-in support for floatable objects (boats, ships and more!) and I wanted to say that it is very impressive having previously used it more than once.

3 Likes

Version 0.0.1

  • Added a name to the project
  • Create a public github repository for the project with support for rojo where everyone can contribute.
  • Published the package to wally
  • Added support for modifiers which allow you to define per cast settings like velocity, gravity and to override event handling

Note: I’m not trying to compete with FastCast, I am just bad at coming up with names

5 Likes

Another great resource by you, good work.

1 Like

Version 0.0.2

  • Added support for native Luau
  • Removed unused variables and cleaned up the code
  • Removed the discard phase, it had cases where a ray would intersect but be discarded, it has also become obsolete following the recent release of native Luau code generation which has given the system a substantial performance improvement overall (Please release native vector SIMD support soon :pray: )
  • Fixed an edge case in the OBB intersection test which would skip an axis if one or more of the size axes were the same (Thanks zeuxcg for pointing it out)
  • Switched to dynamic frame time allocation. It tracks how much time was spent between PreSimulation and PostSimulation to dynamically determine how much frame time is left in the current frame, currently the simulation is allowed to run for half of the remaining frame time.

Note: I have also included a section on performance in the post.

5 Likes

Version 0.1.0

  • Added documentation
  • Removed OOP from the voxels utility
  • Added a Collaterals property to projectiles
  • Added a settings module to allow for easier modification of the system
  • Decoupled the snapshots from the simulation module, snapshots can now be used from outside the simulation
  • Server now correctly detects RaycastFilters using RaycastFilterType.Exclude which intersect characters
3 Likes

Is your system tailored to hit detection on players or will the OnImpact callback fire with any part? I have NPCs and destructible objects that I can be hit by projectiles.

Edit: looked thru API, answered my own question. :face_with_hand_over_mouth:

Sorry to bother you, but it seems like the download link is not there. I don’t know if I’m missing something or like blind or dumb

Hello! I’ve just added the latest version of the module as a release in the GitHub repository.

2 Likes

Thank you for letting me know! Also nice job :+1:

1 Like

Version 1.0.0

  • Improved types
  • Re-structured the documentation
  • Added setup guide to the documentation page
  • Modifiers now take a BindableEvent for each event you want to override instead of overriding every event
  • Added definitions folder to the settings module which allows you to specify an alternative directory to load projectile definitions from
  • Added interpolation handling to the documentation (Make sure to read this as it is key to proper lag compensation) (Getting Started->Simulation->Setting up your server)

With this version I finally have this module in a pretty good place feature wise, I don’t expect to add much more other than a GetPosition() method for projectiles, I will continue to maintain it and fix any bugs as they arise but updates will come at a much more reduced rate.

8 Likes

Why use this over fastcast? Does it have more features or something?

Read the post. He explained everything

1 Like

this looks nice but, other than the features you already talked about, what are the benifits over fastcast?

fastcast is performant and reliable and combined with PartCache makes it better. i looked through the api documentation and saw some things missing that are pretty important to me for customization of the bullet

is there a way to detect when it hits a wall and do a penetration test like fastcast’s CanRayPierce?

am i able to change the look of the bullet, create my own update function for how the bullet moves like fastcast’s OnRayUpdate?

(i could have missed these things in the api, if they were there)

I also want to use this to control NPC interactions (NPCs shooting at players and players shooting at NPCs) I looked through the API and did not figure anything out… Can you share what you found or point me in the right direction?

Thanks

Hey Axen! Great module. I have something very similar but will be planning to this if more reliable than my current solution. Currently mine is about 90% accurate with moving and jumping players (that’s with a pretty big hitbox, using slow moving projectiles).

One question:

How does this module fare with jumping players?
From reading the source code you:

  1. Get the next frame based on the client tick/timestamp
  2. Get the current frame based on the client tick/timestamp
  3. Get a float value probably doing something like math.ceil(timestamp) - timestamp
  4. Use that to lerp for a more precise position

I’ve done this exact solution before but the hitboxes differ from the client by about 0.5~~ studs while jumping, this is including compensation for the built-in replication buffer that Roblox uses.

From my own testing that buffer is about 9/60s (0.15s) - I use 60 as thats the maximum number of ticks/s that servers can output. If your solution actually doesn’t have the issues I’ve laid out, I’d really appreciate having a chat about this!

Also a suggestion: try implementing a circular queue instead of using table.insert() and table.remove(). Will probably squeeze a bit more performance out of your code.