#Enemy AI can't catch up to me
24 messages · Page 1 of 1 (latest)
it does
function checkSight(target)
local ray = Ray.new(Head.Position, (target.Position - Head.Position).Unit *magnitude_whenClose)
local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, {enemyModel})
if hit then
if hit:IsDescendantOf(target.Parent) and math.abs(hit.Position.Y - Head.Position.Y) < 3 then
if isChasing == true then
enemyHumanoid:MoveTo(target.Position)
return true
end
end
end
return false
end
magnitude_whenClose is 14
Thats odd
I feel bad because hitbox has to be huge
It seems that its a replication issue
and setting network owner to player will stutter even more
(for certain npcs)
I have tried fixing this for so long but I can't
Try playing again, and look at what the server sees.
Sorry for being off topic but you are seriously using bandicam?? 😭
bro I swear
You need to give the AI a predicted path that goes further away from the Character
This happens because a server has a delay whenever it's replicating clients.
That's how servers work and you should be aware of this already if you played FPS games.
Guess making very big Hitboxes can help.
welp, now the issue is solved, thanks to everyone who tried
.
@silent prawn Here
function checkSight(target)
local ray = Ray.new(Head.Position, (target.Position - Head.Position).Unit * magnitude_whenClose)
local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, {enemyModel})
--// Exit function early
if not isChasing then return false end
if not (hit and ray) then return false end
if not (hit:IsDescendantOf(target.Parent) and math.abs(hit.Position.Y - Head.Position.Y) < 3) then return false end
--// Calculate target's velocity
local targetVelocity = target.Velocity
--// Predict the target's future position
local predictionTime = 1.5 --// how far ahead to predict
local predictedPosition = target.Position + (targetVelocity * predictionTime)
--// Calculate the distance between the AI and the predicted position
local distanceToPredicted = (predictedPosition - Head.Position).Magnitude
--// If the predicted position is too far, cap the distance
local maxPredictionDistance = 30 -- Adjust this value as needed
if distanceToPredicted > maxPredictionDistance then
local direction = (predictedPosition - Head.Position).Unit
predictedPosition = Head.Position + direction * maxPredictionDistance
end
enemyHumanoid:MoveTo(predictedPosition)
return true
end
** You are now Level 22! **
Already fixed it