Making Dot Follow Cursor

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a dot smoothly follow the player’s cursor in first person.

  1. What is the issue? Include screenshots / videos if possible!

It’s not smooth. Games like Arsenal are able to do it perfectly well (https://gyazo.com/e1e75f020fb668e34d691854bd45d99c) (especially impressive because they get it on the server, which I’d also like) but when I try it, it looks like it lags behind (https://gyazo.com/de9e00193365e542cc1393cfa813c63a).

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have looked for a solution on the forums; nothing came up. I went into ROBLOX’s Mouse documentary and tried the code there. No results.

Right now, the server replication isn’t my main priority. Just trying to get it smooth.

It should be noted that the dot is smooth with mouse movement in third-person; it only looks choppy in first-person.

Any help would be appreciated!

1 Like

Im guessing they just shoot a ray cast from the players camera each time the cameras CFrame updates?

Also how do you know if it’s on the server? There will always be latency between the client and server, there is just no avoiding that (unless with something very advanced), I don’t see a point in making it on the server, its just slower and from what I can see, will only be a visual thing, not a main game mechanic. So making it on the server is just unnecessary, I would love to hear your view though.

But anyways, since this is a visual thing, I guess make 2 separate objects, make one that’s smooth that only works on the client, and a second one that is invisible and works on the server, so you get the smoothness from the client and the replication on the server.

1 Like

I’m not sure how they do it but other players can see the person’s dot.

I guess do this approach, but replicate the invisible dot to other players, because in arsenal, its so fast paced, the latency from the servers dot will probably barely be noticed by the player/players.

The problem is getting the client object to be smooth, though. Thats the whole reason I made this post - I tried using RenderStepped and it gave me that choppiness that you see in the video.

I also don’t see the point of RayCasting if Mouse.Hit works just as well, but maybe you know something I don’t.

1 Like

on the client use stepped and mouse.hit to get a smooth dot

then send the position of the dot to the server constantly and tween the dot position on the other clients

1 Like

tried it. tried renderstepped too.

Tbh, the mouse object is probably going to be deprecated soon, and is outdated, I would use UserInputService instead, but I digress.

Are you able to show me the script you used in the video? And tell me if the script is on the server or client please.

Yes.

Taken from the ROBLOX Mouse documentary and edited.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer

local mouse = player:GetMouse()

local attachment0 = Instance.new("Attachment")
local attachment1 = game.ReplicatedStorage.GreenDot.Attachment:Clone()
beam.Attachment0 = attachment0
beam.Attachment1 = attachment1

attachment0.Parent = workspace.Terrain
attachment1.Parent = workspace.Terrain

local function onRenderStep()
	local character = player.Character
	if not character then
		return
	end

	local head = character:FindFirstChild("Head")
	if not head then
		return
	end

	local origin = head.Position
	local finish = mouse.Hit.Position

	attachment0.Position = origin
	attachment1.Position = finish
end

RunService.RenderStepped:Connect(onRenderStep)

you cant make the dot perfect on the server, but i think the problem in the video from the client side is caused by the wrong render priority

use this instead of renderstep, and tinker with the render priority until it looks right

RunService:BindToRenderStep("anyStringHere", Enum.RenderPriority.Camera.Value, function(dt)

end)
1 Like

Worked like a charm. Instead of Camera I used Character. Thanks!

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