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