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

You said you added NPC support but how would I implement that? Also, is there a specific method I should use to delete the bullet and do you know how I could implement partcache/objectcache into the module?

Sup, so I have a problem where the other player takes no damage and can’t figure out what causes that.

External Media

Update: I fixed it but the cause is still unknown to me.

Just started using this module today. Thanks for your work.

Setting up your workspace
SecureCast requires a Map and Characters folder placed within workspace to function correctly.
All parts of the map must be a descendant of the Map folder.
All player characters must be paranted to the Characters folder.

We will also need an Events folder within ReplicatedStorage. Add a RemoteEvent named Simulation under the Events folder.

Is there a reason why the module doesn’t do this itself? If not, I’ve opened a PR on the repo that you can review to add this as an option

2 Likes

Is there any callback after the projectile moves? Example would be FastCast’s “OnLengthChanged” callback, it would be very useful

Not exactly sure. I don’t know the behavior of OnLengthChanged.

For this module, I’ve just been editing in a lot of the behavior I want. The insides of this code is pretty straight forward.

Tags also work just fine with the PVInstance projectiles so hooking up tag observers to those may be a path forward for you as well

Well basically every render of the projectile sends a “signal” and callback called “OnLengthChanged” in fastcast

Yeah I think you could implement something like this under the loop OnPostSimulation() or listen to when the position is changed on the projectile instance

I think they mean something similar to C# where you do “override class SecureCast:Gun”, basically making Gun a subdivision

Why doesn’t secure cast use OOP tho?

Id assume because it uses parallel lua. Anyways there’s not a very great reason for it to use OOP as you can make your own classes which each utilize SecureCast

I need some table attached to each bullet, table where i can put mainly connections, with OOP it’s easy but without it idk where or how to do that, fastcast had it’s own Caster.UserData table for each bullet and i find it VERY useful

Hello, I am getting an issue in which when the bullet bounces and loses velocity, if the velocity is too low it will sink through the floor. This is an issue if you have multiple floors in your map. This happens in the example place with no modifications apart from adding a modifier with Loss and Velocity while the angle is 360.

EDIT: I have achieved a temporary fix by checking if the Velocity.Magnitude ever becomes smaller then 10 then destroying the projectile, but now I am wondering how can I make impact events that are only client sided or only server sided? e.g. a smoke grenade should only be created on the server not both the client and the server.

Add a server check (one-time per context) that calls/runs OnImpact code

Can you elaborate please? I am not entirely sure where this would go. I am using onDestroyed as a function in the Bullet class

wow that was a quick response,
create if statement checking if this is true or false
RunService:IsClient()

if its true its on the client and you continue with your smoke grenade code and false you return

1 Like

Hello!
I have some issues with hit register with players. NPC can take damage and die but players not.

Check the “IsPlayerFriendly” function. By default it only allows damage to players on opposite teams

ReplicatedStorage.ModuleScripts.SecureCast.Simulation:212: attempt to index nil with 'Player'  -  Server - Simulation:212
  19:11:38.449  Stack Begin  -  Studio
  19:11:38.449  Script 'ReplicatedStorage.ModuleScripts.SecureCast.Simulation', Line 212 - function RaycastPlayers  -  Studio - Simulation:212
  19:11:38.449  Script 'ReplicatedStorage.ModuleScripts.SecureCast.Simulation', Line 353 - function OnPostSimulation  -  Studio - Simulation:353
  19:11:38.449  Stack End

Getting this error. Dont know why this is happening. Happens on some occasions when I kill an npc. Haven’t tested killing a player

I think it errors sometimes when I start moving a lot and kill an npc. However, it is still extremely weird as I can’t replicate it every single time.

I believe I found a temporary fix for this error. Around line 216 in the Simulation module there is this code:

--> Avoid checking teammates
		local Player = NextRecord.Player or PreviousRecord.Player
		if Player and IsPlayerFriendly(Caster, Player) then
			continue
		end

Below there should be some code saying:

--> Previous record is guaranteed to exist due to it being in the grid
		if not NextRecord then
			continue
		end

If you move this code above it should work