I don’t know what the cause of this could be. Still, after switching to the server I noticed that the position of the rocket (the white part) and the position of the blast radius visualizer (the red part) are off on the client in terms of position, but accurate on the server.
How does your system work? Is the blast radius coded server sided? On what context do u want the blast radius to be used for? Based on this you might have to alter your code to client side and use remote functions/events and sanity checks.
client: sends remote event to the server with the args containing the player and the mousePos
server: creates the rocket, sets the cframe and velocity, calls an explode function in the rocketModule.
rocketModule: stops movement of the rocketPart, creates a region3 that serves as the hitbox of the explosion, emits explosion particles, and then creates an explosion visual using the visualizerCalculator function. The wait was only used so that I can swap between the server and client to check the position of the rocketPart.
serverCode:
rocket.CanCollide = false
rocket.CFrame = CFrame.new((tool.Handle.CFrame * CFrame.new(5, 0, 0)).Position, pos)
rocket.AssemblyLinearVelocity = rocket.CFrame.LookVector * rocketData.rocketSpeed -- Set the rocket's linear velocity.
rocket.CFrame *= CFrame.Angles(0, math.rad(90), 0) -- Change its orientation so that the rocket is facing the direction that it's going in.
moduleCode:
rocketPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
rocketPart:FindFirstChildOfClass("BodyForce"):Destroy()
rocketPart.Anchored = true
task.wait(10)
local region3 = Region3.new(
rocketPart.Position - Vector3.new(rocketData.range.L, rocketData.range.H, rocketData.range.W),
rocketPart.Position + Vector3.new(rocketData.range.L, rocketData.range.H, rocketData.range.W)
) -- Creates a region3 that destroys any parts in the explosions radius.
local explosionClone = explosionParticles(rocketPart, rocketData)
explosionClone:Emit(100)
local explosionVisualizer
if debugMode then explosionVisualizer = visualizerCalculator(region3) end
function visualizerCalculator(region3)
local region3Visual = Instance.new("Part") -- The visualized part for the region3.
region3Visual.Name = "blastRadiousVisual"
region3Visual.CanCollide = false
region3Visual.CanTouch = false
region3Visual.Size = region3.Size
region3Visual.CFrame = region3.CFrame
region3Visual.Anchored = true
region3Visual.Transparency = .5
region3Visual.Parent = workspace.Terrain
region3Visual.BrickColor = BrickColor.new("Persimmon")
return region3Visual
end
Seems like it has to do with the delay of serverside to clientside replication. Based on this, if your looking for visual only i suggest you do anything visual related on the client. Anything that has to do with actually modifiying the workspace can be done in the server. also based on these images could I see more refrence
could you like make the character position the same on both? and yeah it seems like a replication delay since the server sided part goes farther than the client sided
Yeah, on the client it doesn’t even look like the rocket hit anything and so its just suspended in air, but in actuality it ran into the ground and later exploded.
what if you removed the wait. Do you see the client visually see a delay right after the explosion or is it correctly displaying (hit something then explode rather than explode before hit in the client)?
It’s hitting something and then exploding correctly on the client, the position is just being wonky.
I also noticed that when the rocket speed is higher, the offset of the positions between the server and client is more noticeable, while a lower speed will yield more accurate results on the client.
Like i said the inconsistency is due to the replication from server to client. It might also have to do with the NetworkOwnership system roblox uses with client and server. As the part moves farther away from you, you no longer own the network of the part therefore delaying the movement in the client. You can read about it here. (Inconsistencies could also be due to interference of other code ran through that the server deems as more important)
In my opinion I suggest that make separate code for the visual (the rocket) for the client only and separate code for the actual explosion in the server only. You might have to figure out some sort of system for that (ex if u want other people to see the visual i suggest having a remote event that fires that visual to all players and not just create a part for use as a visual in the sever only → This can be also be a better option as you have more control over visuals [such as settings, etc] and less pressure put on the server.)
relying on more reliable rational calculations is also a valid option:
Here’s a video I suggest:
You can try watching the video to give you an idea on what to modify. I cannot guarantee this though because it depends what is running in your game simultaneously but I suggest just give this one a try first as its the easiest option for you right now.
Yeah, I’d much rather prefer something else because I don’t want to make visuals on the client and then have to deal with players changing stuff on the client and whatever. It’s probably much simpler than that but I prefer just having the client send a position, the rocket be created on the server, and then it explodes accurately on both the client and server.
Keep in mind no visual is going to be done on the server, the server just calculates the end position and the explosion time so really if an exploiter changed anything he’s only changing what he sees and not other players perspective as each player has their own separate client visual from the remote event.
I meant to say rational but if you look at the video he uses different calculations to determine accuracy in his projectiles. He seems to use gravity, actual physics calculations such as (v = Δd/Δt, forces) and also sets his networkownership to nil which if you want could attempt that right now but i’m not sure how that would affect that.
Well, that’s fine but I still want to keep it simple, I’ve seen older games use projectiles like doomspire, but I don’t think the weapons do any of that to actually work, compared to mine.
Did you also do this to your projectile? This is something I’ve seen on even the old rocket launcher. Setting the NetworkOwnership to nil could help solve your answer. Give it a shot.
Edit: Logically I think this should be the answer to your problem since setting the NetworkOwnership to nil forces the projectile to only be owned by the server therefore not having that wacky delay on the client due it being out of range (like i mentioned earlier). Hopefully it solved your issue.
The only thing now that I have to do is figure out where I can put the touched event because I want it to stay within the server script that creates the rocket, but as we know that causes there to be some sort of replication lag.