FIRST OF ALL THANKS FOR EVERYONE THAT READS THIS TOPIC
-
What do you want to achieve?
I want to update my character client position to my character server position -
What is the issue?
Im currently working on a game that relies on fast movement and precision,but it seems like it’s not that accurate:
The RedPart is where the server sees my character, I want so Its almost in the same position as the character, basically clipping.
Why I want that? Imagine this are players. Player2 will always sees player1 as the RedPart, this would generate massive collision problems.
For an example in Blade Ball u get hit by the ball before it actually hits your character. “That seems to be a problem in Blade Ball but I can’t confirm or state it, I’m also not judging or complaining about the Blade Ball Collisions”
-
What solutions have you tried so far?
I’ve tried to implement an interpolation system using lerp or tween, but it doesn’t seems to work:
Server Side:
local runService = game:GetService('RunService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local remotesFolder = replicatedStorage:WaitForChild('Remotes')
local unreliableUpdateLocation = remotesFolder:WaitForChild('UnUpdateLocation')
local lastUpdate = tick()
local diference = 1/30
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local red = Instance.new('Part', workspace)
red.Color = Color3.fromRGB(255, 0, 0)
red.Size = Vector3.new(3,3,3)
red.Anchored = false
red.CanCollide = false
red.Transparency = 0.2
runService.Heartbeat:Connect(function()
local pos = char.PrimaryPart.Position
red.Position = pos
red.Rotation = char.PrimaryPart.Rotation
-- UpdateLocation
if (tick() - lastUpdate) > diference then
unreliableUpdateLocation:FireClient(player, pos)
lastUpdate = tick()
end
end)
end)
end)
Client Side:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local linear = char.PrimaryPart:WaitForChild('LinearVelocity')
local moveSpeed = 20
local mouse = player:GetMouse()
local tween = game:GetService('TweenService')
local info02 = TweenInfo.new(2, Enum.EasingStyle.Linear)
local info = TweenInfo.new(0.25, Enum.EasingStyle.Linear)
local runService = game:GetService('RunService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local remotesFolder = replicatedStorage:WaitForChild('Remotes')
local unreliableUpdateLocation = remotesFolder:WaitForChild('UnUpdateLocation')
local UpdateLocation = function(vectorPos)
local lerp = char.PrimaryPart.Position:Lerp(vectorPos, .5)
end
local HeartBeat = function(dt)
local target = Vector3.new(mouse.Hit.X, char.PrimaryPart.Position.Y, mouse.Hit.Z)
tween:Create(char.PrimaryPart, info, {CFrame = CFrame.lookAt(char.PrimaryPart.Position, target)}):Play()
linear.VectorVelocity = char.PrimaryPart.CFrame.LookVector * moveSpeed
end
unreliableUpdateLocation.OnClientEvent:Connect(UpdateLocation)
runService.Heartbeat:Connect(HeartBeat)
"EDIT: The RedPart is simulating where the server sees the player at. I want the player to go to the RedPart position (where server sees it)
I tried to make a video with server, and 2 client perspectives but wasn’t able to (Due to FPS). Imagine that:
Server: Player1 and Player2 are at position 5
Client Player1: Player2 is at position 4 or 5, I am at position 6
Client Player2: Player1 is at position 4 or 5, I am at position 6
While server sees them paired with each other, the P1 sees himself in front of P2 and P2 sees himself in front of P1"