Client-Sided Velocities Used on Projectiles Make them have an Innacurate Hitbox

First explaining how the game works, it is a game of four elements where players control projectiles like fire balls, earth boulders and water streams with their mouse (it’s a loop that keeps checking the mouse position and then change the velocity of the projectile). However, since I, people of my country, and other people of Roblox have more than 150 ping, I’m not making those projectiles get the player’s mouse position, send to the server, and then make the velocity of the projectile move that way in the server (which would have a very huge delay depending on the ping), but give the network ownership of the part (projectile) to the player who shoot it and then fire a client event to make it move to the position of the mouse of the player (which has no or almost no cooldown).

The issue, however, is that the hitboxes of those projectiles are very innacurate. The first innacuracy example I can give is that the projectiles always hit other characters with like 5 studs of distance (even in the POV of the player who has the network ownership of the projectile); the second example is, if the character use a move that shoots 2 projectiles with a small delay between each, the first projectile will hit the player with the same 5 studs of distance, and the second will hit the player in the same location the first projectile hitted the character (in all POVs the second projectile is very far away from the character that got hit by the first projectile, since there are knockbacks). And yeah, that happens even when the opponent is standing still.

My goal is just making those hitboxes look as accurate as server-sided projectiles that keep updating their position, or at least a bit more accurate than it is now. The people that play my game are really complaining about that, and I also don’t like this.

Also, I was thinking if there was a way to make the projectiles be smooth for the player who shoot it, but be laggy and accurate for other players (assuming the inaccuracy is only visible for the players and not for the server). And yes, the Touched event is connected on the server.

I’m not sure if I can provide any videos now, but if someone asks here I’ll try to get one. I also haven’t tried anything, because I just don’t have any idea about what I should do. Also, there are barely people or games with this kind of combat, so I couldn’t find anything on any website.

So my first question is what are you using to move these projectiles, I know you said you give the player network ownership of them but how are you moving them on the client?

1 Like

I send a BodyVelocity instance created on the server that has 100000 MaxForce on each vector (just so if the player lags the projectile won’t fall from the map, but instead stand still without being anchored) to the client, and change the velocity. here’s the remote event that does that:

clientAim.OnClientEvent:Connect(function(projectile: BasePart, Velocity: BodyVelocity, speed, delayTime)
	mouse.TargetFilter = workspace
	Velocity.Velocity = (mouse.Hit.Position - projectile.Position).Unit * speed

	local redirection = Services.RunService.RenderStepped:Connect(function()
		projectile.CFrame = CFrame.new(projectile.Position, mouse.Hit.Position)
		Velocity.Velocity = projectile.CFrame.LookVector * speed
		-- Velocity.Velocity = (mouse.Hit.Position - projectile.Position).Unit * speed
		task.wait()
	end)
	task.delay(delayTime, function()
		redirection:Disconnect()
	end)
end)```
1 Like

I managed to fix this anyway, and I finished making the game some weeks after fixing it. So, basically, it’s a problem from the .Touched event itself I believe, but you can fix it using a loop that constantly checks if there’s anything touching the hitbox using the :GetTouchingParts() method. However, doing this fixes the hitbox only for the players who don’t control the projectile, since the projectile’s velocity is handled client-sided. What happens now is just a bit of innacuracy where the hitbox is always not really where it is for the client who controls it because of the client-server delay, so it also depends a lot on your ping to notice if it is innacurate for you or not

In addition, I’ve noticed that .Touched events work way better (in case you’re not making something like a projectile with a velocity handled client-sided) with a Heartbeat loop that constantly replaces the projectile in its same CFrame. For example, a .Touched event will be way more accurate if you have a Heartbeat loop setting [projectile].CFrame = CFrame.new([projectile].Position, [projectile].CFrame.LookVector)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.