I am creating a sort of tank system. where you shoot a projectile. and the camera stays on the projectile. The problem is that i need to check for collisions realtime so i cannot pre determine trajectories.
I use assemblylinearvelocity for the launching but due to roblox physics replication it will always be slightly delayed on the client. so i have created a exact clone of the projectile on the client. that will follow copy the projectiles properties. including assemblylinearvelocity.
the problem is is if the projectile creation remote is late (i already only send buffers to maximise networking), the clients projectile will be desynced from the server since the server checks for the collisions.
This delay is not that big. but when your camera is focussed on the projectile it is very noticable.
I have tried correcting the trajectory on the client. but this makes it feel less natural even the slightest snappyness will ruin how satisfying it is.
I have tried comparing previous network times to account for the remote delay but ofcourse this is also snappy.
My only thing that seems possible anymore is rendering the projectile on the client and also the hit detection and telling the server. But of course this can be manipulated which i do not want.
What im doing is creating an explosive on the server:
-- this creates an explosive from the explosive class
local Explosive = Explosive.new(Player, StartCFrame, LaunchVelocity, 20, Assets.Explosives.Firecracker)
When a hit is detected it triggers this event
Explosive.Exploded:Once(function(ExplosionCFrame : CFrame)
When the client receives a projectile creation remote:
-- creates a clone of the server projectile
local ClientExplosive = self:CreateClientExplosive(ExplosionStats)
-- would hide the server projectile on the client
for _, Part in ExplosionStats.ServerExplosive:GetChildren() do
if Part:IsA("BasePart") then
Part.Transparency = 0.5
end
end
-- puts the camera on the clients explosive
CameraController.SetCameraType(Enum.CameraType.Custom)
CameraController.SetCameraSubject(ClientExplosive)
Let me know if you know what else i can try, Thanks!