How You Can EASILY Make A Pathfinding AI In Under 3 Minutes!

preview_player
Показать описание
EASY How To Make A Pathfinding AI In ROBLOX STUDIO!
#roblox #robloxstudio #horrorgaming #scripting

This is a Roblox Studio tutorial on how to make a Pathfinding AI in Roblox. Like Roblox Doors. I hope you enjoy and learn how to make your very own Roblox game. This includes a PATHFINDING AI, which follows you using the quickest possible path. I hope you enjoy the videos.

----------
----------
----------
----------
----------

What is Roblox?
Roblox is an online game platform and game creation system developed by Roblox Corporation that allows users to program games and play games created by other users.

----------

Music: Evan King - Spicy Boom

----------

Music: Evan King - Virtually Impossible

----------

Music: Evan King - Atomic Fire

#Roblox #RobloxStudio #robloxdoors #doorsroblox #horrorgames2021 #pathfinder #robloxpathfinding #pathfinding #robloxai #robloxgame #robloxstudiogame #robloxstudiotutorial #robloxhowto #howtomakearobloxgame #howtomakeahorrorgame #howto #howtomake #howtocode #howtocodewell #howtoscript #robloxstudiotutorials #robloxstudios #robloxscripting #robloxscarygames #robloxscary #robloxscript #robloxscripts #robloxscript2022 #robloxrpg #robloxdoors #robloxtrend #robloxprofile #robloxdown #robloxdev #robloxedit #howtocreate #creative #coding #code #codes #robloxgames #robloxtutorial
Рекомендации по теме
Комментарии
Автор

If you want do a npc move to a part use this script

Local pfs =
Local NPC = script.Parent
Local part = workspace.Part

Local path = pfs:CreatePath()
path:ComputeAsync(NPC.HumanoidRootPart.Position, part.Position)

For _, waypoint in pairs (path:GetWayPoints()) do


End

Pls leave a like its so disgusting do this on moblie💀

FNTS_OFCC
Автор

I figured out a cool trick to allow pathfinding to go up and down stairs. It's very simple. All you have to do is add a "PathfindingModifier" to the stairs and the Pathfinding System acknowledges that the stairs can be used when needed! (I have tested it, it works.) I still want to figure out how to limit the Y axis so it doesn't follow a player that is upstairs.

couchwow
Автор

Script:
-- Variables --

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

local Enemy = script.Parent
local Humanoid =


local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

local WalkSpeed =
local SprintSpeed =
local Damage = Enemy:GetAttribute("Damage")

-- Functions --

local function getPath (destination)
local path = Pathfinding:CreatePath({
AgentHeight = 6;
AgentRadius = 3;
AgentCanJump = false;
AgentCanClimb = false;

Costs = {
Water = 100;
DangerZone = math.huge
}
})

path:ComputeAsync (Enemy.HumanoidRootPart.Position, destination.Position)

return path
end

local function findTarget()
local nearestTarget
local MaxDistance = 50

for index, player in
if player.Character then
local target = player.Character
local distance = -

if distance < MaxDistance then
nearestTarget = target
MaxDistance = distance
end
end
end

return nearestTarget
end

local function Capture (target)
local distance = - .Magnitude

if distance > 3 then

else
target.Humanoid.TakeDamage (Damage)
end
end

local function walkTo (destination)
local path = getPath(destination)

if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints ()) do
local target = Pathfinding ()

if target then
Capture(target)
Enemy.Humanoid.WalkSpeed = SprintSpeed
break
else
Enemy.Humanoid.WalkSpeed = WalkSpeed
Humanoid:MoveTo(waypoint. position)
()
end
end
else
- Enemy *10))
end
end

local function Patrol()
local waypoints =
local randomWaypoint = math.random(1, #waypoints)

end

-- Main Program --

while wait(0.01) do
Patrol()
end

NostalgiaOnly-qskl
Автор

Make sure to still watch the whole video for context

local pathfinding = game.PathfindingService
local players = game.Players
local runService = game["Run Service"]

local enemy = script.Parent
local humanoid =


local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

local walkSpeed =
local sprintSpeed =
local damage = enemy:GetAttribute("Damage")
local maxDistance =

local function getPath(destination)
local path = pathfinding:CreatePath({
AgentHeight = 6;
AgentRadius = 3;
AgentCanJump = false;
AgentCanClimb = false;

Costs = {
Water = 100;
DangerZone = math.huge
}
})

path:ComputeAsync(enemy.HumanoidRootPart.Position, destination.Position)

return path
end

local function findTarget()
local nearestTarget
maxDistance =

for index, player in pairs(players:GetPlayers()) do
if player.Character then
local target = player.Character
local distance = -

if distance < maxDistance then
nearestTarget = target
maxDistance = distance
end
end
end

return nearestTarget
end

local function capture(target)
local distance = -

if distance > 3 then

else

end
end

local function walkTo(destination)
local path = getPath(destination)

if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
local target = findTarget()

if target then
capture(target)
enemy.Humanoid.WalkSpeed = sprintSpeed
break
else
enemy.Humanoid.WalkSpeed = walkSpeed


end
end
else
- * 10))
end
end

local function patrol()
local waypoints = workspace["AI Waypoints"]:GetChildren()
local randomWaypoint = math.random(1, #waypoints)

end

while wait(0.01) do
patrol()
end

themaydayman
Автор

Ok, here is an error I noticed when testing the AI out. Sometimes, when a player comes into the AI's range, it'll have a seizure. It can't make up it's mind on whether it should go to the waypoint or the player, so it just constantly spins, and after the player get out of view it will try going directly to the waypoint without navigating and run into walls. I don't know if this is a roblox error, a problem with falling from two floors, or this is a mistake in the code.
Just sending feedback!

couchwow
Автор

FULL SCRIPT!!!!
(Remember to make the attributes and waypoints)


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

local Enemy = script.Parent
local Humanoid =


local waypoints
local nextWaypointIndex
local reachedConnection
local blockedConnection

local WalkSpeed =
local SprintSpeed =
local Damage = Enemy:GetAttribute("Damage")

local function getPath(destination)
local path = Pathfinding:CreatePath({
AgentHeight = 6;
AgentRadius = 3;
AgentCanJump = false;
AgentCanClimb = false;

Costs = {
Water = 100;
DangerZone = math.huge
}
})

path:ComputeAsync(Enemy.HumanoidRootPart.Position, destination.Position)

return path
end

local function findTarget()
local nearestTarget
local MaxDistance = 100

for index, player in
if player.Character then
local target = player.Character
local distance = -

if distance < MaxDistance then
nearestTarget = target
MaxDistance = distance
end
end
end

return nearestTarget
end

local function Capture (target)
local distance = -

if distance > 3 then

else

end
end

local function walkTo(destination)
local path = getPath(destination)

if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
local target = findTarget()

if target then
Capture(target)
Enemy.Humanoid.WalkSpeed = SprintSpeed
break
else
Enemy.Humanoid.WalkSpeed = WalkSpeed


end
end
else
- *10))
end
end

local function Patrol()
local waypoints =
local randomWaypoint = math.random(1, #waypoints)

end

while task.wait(0.01) do
Patrol()
end

ivanminigu
Автор

The tutorial is very short but almost too short where im left to spending time pausing the video and rewinding because of the blurry effect you applied to all of the transitions

JimmyButBetter
Автор

cool tutorial, except next time it would be cool if you actually explained what does what mean and do and not just throw some code at me without any explenation of what it really does and means

just saying

zwierze
Автор

Is there a way to disable it from chasing the player?

NVM I just set maxdistance to 0 and it worked

akamccookie
Автор

BRO IT DOESNT EVEN WORK I DONE EXACTLY WHAT I NEEDED TO DO

samgaming
Автор

1. It wasn't easy.
2. It didn't worked.
👎

Vratislav_IV
Автор

My did not work :( I followed it step by step but it didn't work, I think there might be a problem with my mesh rig or possibly the script.

Captain_Butterfingers
Автор

for some reason, when using the script, not only does the AI sometimes get stuck in walls, and keeps spinning when the player is close to it, but also the animation really doesn't play that much. I made an animation for the AI but it only sometimes plays. I usually doesn't play at all getting close to the player. Is there a fix?

dogerr_
Автор

for those that are having problem with the npc spinning when close to a player, try increasing the agent's height

pocketdeveloper
Автор

Finally, a simple pathfinding tutorial without run time lag that is quick and easy to implement and allows a lot of modification.👍

ChknNugz
Автор

Video Title: Under 3 Minutes

Reality: 30 minutes

Raman_bruh
Автор

Hello! How do i make it so the enemy has his own punch anim

ivanminigu
Автор

So i followed all the script, and my AI only goes to the blocks instead of the people. How do I fix this?

kofiboateng
Автор

How to make it so that when ur like near the npc it will like wake up and chase you around then it will go sleep again after some seconds?

CoolDaPosts
Автор

hey! I need help with the script, can you copy paste it pls! bc i tried it doesnt work. i dont want to do that hard work again

WaffleWafi