#Jittery ball when on low fps

1 messages · Page 1 of 1 (latest)

lilac falcon
#
-- Client
local function UpdateProjectile(Index, CurrentPosition, A, Velocity, dt)
    local CurrentDodgeball = Dodgeballs[Index]
    if CurrentDodgeball then
        local Time = tick() - dt
        local SteppedVelocity = Velocity + A * Time
        local SteppedPosition = CurrentPosition + SteppedVelocity * Time
        CurrentDodgeball.Position = SteppedPosition
        
    end
end

-- Server
local Time = tick()
Remote.UpdateProjectile:FireAllClients(index, CurrentPosition, A, Velocity, Time)

it shouldn't be jittering, i dunno why it is

#
local Conversion = 196.2/9.8
local Velocity = (dest - start).Unit * force * Conversion
        
local A = Vector3.new(self.Wind.X, self.Wind.Y - self.Gravity * 9.8, self.Wind.Z) * Conversion -- wind is 0
        
local T = 0

while true do
    local dt = task.wait()
    T += dt
            
    -- v = v0 + at
    CurrentVelocity = Velocity + A * T
            
    local ProjectilePosition = Vector3.new(
        start.X + Velocity.X * T + 0.5*T*T,
        start.Y + Velocity.Y * T + 0.5*A.Y*T*T,
        start.Z + Velocity.Z * T + 0.5*T*T
    )
    RayResult = workspace:Raycast(CurrentPosition, ProjectilePosition - CurrentPosition, self.Params)
            
    local Time = tick()
    Remote.UpdateProjectile:FireAllClients(index, CurrentPosition, A, Velocity, Time)
            
    CurrentPosition = ProjectilePosition
end
timid cedar
#

Don't use single character varaible names, it makes your code hard to read

lilac falcon
#

alr

timid cedar
timid cedar
#

That will remove any jitter from network lag

#

You could also use unreliable remote events if you don't want to simulate it synced on the clients. Unreliable remote events aren't granteed to be recived and aren't garunteed to be in the order they were sent. They are useful for things that need to be updated frequently but don't suffer if a single message is lost. They are faster.

lilac falcon
#

so either work with unreliable remote events (which can be sent in the wrong order or may be lost) or have the calculations along with the visualization on the client?

timid cedar
#

which can be sent in the wrong order or may be lost
A lost event doesn't matter, to handle out of order events just send an index along with any event and when an event is received drop any that have a lower index than the highest index you've received so far.