#Enemy AI
1 messages · Page 1 of 1 (latest)
well you are teleporting the ai
to the player
Imma send my attack logic for you
one sec
while os.clock() - Start < 15 and Distance < GRANDMA_CONFIG.MaximumDistance do
Humanoid:MoveTo(Closest.PrimaryPart.Position + Closest.Humanoid.MoveDirection * 3)
local newClosest, newDistance = self:FindClosestCharacter()
Distance = newDistance
if newClosest ~= Closest then break end
if Closest:GetAttribute("Invisible") then break end
if Distance < GRANDMA_CONFIG.HitDistance then
print("Killed player")
Closest.Humanoid.Health = 0
Closest.PrimaryPart.AssemblyLinearVelocity = Vector3.new(math.random(1, 9) * 10, 100, math.random(1, 9) * 10)
break
end
if self:InLineOfSight(Closest) then
Lost = os.clock()
end
if os.clock() - Lost > 4 then
print("lost player")
break
end
task.wait()
end```
its pretty similar to what you have
the only difference is some knockback and other thinggs
also
For the moveto part, to make sure the ai will always before infront of the player
or close to it
I take into account the Movedirection, and make it so it tries to move infront of the players current position
i would recommend setting networkownership to the player being chased
to avoid network latency for that player
k I'll try it out
Thanks, finally got a decent system for it to work, not really sure about the whole networkownership thing yet though
Problem is right now, whenever I do a huge burst of velocity/movement with my slide ability, it causes the enemy to follow with a huge burst of movement to follow me
try doing MoveDirection.Unit
I forgot to do that in my own script
but didn't affect it as much because I don't have a dash ability
theRootPartOfTheEnemy:SetNetworkOwner(playerBeingChased)
but first check it with theRootPartOfTheEnemy:CanSetNetworkOwnerShip()
i think the default networkownership is decided by the server
keep in mind if a player has NetworkOwnerShip on something, that player will be able to exploit to send it somewhere else (with cheats ofc)