Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Mob pathfinding like minecraft zombies?

Asked by 4 years ago

So I'm making a dungeon game, and I want there to be guards that you have to kill, i would just retexture the default roblox player tracking mob, but it pathfinds through walls, so it's not very good for what I'm wanting to do.

Basically I want it to pathfind like a Minecraft zombie (doesn't pathfind through walls), but I'm unsure of how to do so.

If anyone could maybe share how I would do that, I would greatly appreciate it.

1 answer

Log in to vote
1
Answered by
TGazza 1336 Moderation Voter
4 years ago

The following code is little sniplets from my npc George, hes quite advanced. You can find him in person here:

https://www.roblox.com/library/331847610/Its-George

He can also (or could) drive vehicles and did i mention he can also get travel sick! :P

lol anyway the basics of his path finding is below. Your more than welcome to download him and disect his brain (he's kinda used to me doing it! lol)

Code:

01local Self  = script.Parent  -- Base
02local ME        = Self.Humanoid -- My Brain! :D
03local Path  = {}            -- a Table that holds the points of our path
04local CurrentPoint = 1      -- Current point on our path to our destination
05 
06local function computePathtoV3(Target)
07    local PFS = game:GetService("PathfindingService")
08    local path = PFS:FindPathAsync(Self.HumanoidRootPart.CFrame.p,Target,1024)
09    return path:GetWaypoints()
10end
11 
12 
13-- wrap this in your target finder function/bit!
14--[[
15kinda like
View all 38 lines...

Each time your npc gets to the end of a path you would clear the Path table and resetting the path index (CurrentPoint ) to 1

aka:

1Path = {}
2CutrrentPoint = 1

Hope this helps! :)

0
what line does the normal pathfinding start? all I can find seems like just vehicle stuff (in the full model you sent) gwenniekins 59 — 4y
0
also the script you sent doesn't match anywhere in the model you sent me... gwenniekins 59 — 4y
0
yeah the script i posted here is the path script section. Its in the Brain script inside him. the computePathtoV3 is at line 145 and look right down the bottom of the script for where he walks the path. TGazza 1336 — 4y
0
Just search for the varable "Path" and you'll see TGazza 1336 — 4y
Ad

Answer this question