
AI Monster Pathfinding -Teddy Horror Game #2
GnomeCode
Views: 422619
Like: 9062
We’re continuing with our Piggy inspired horror game ‘Teddy’.
Missed the last part? Check out part 1 here:
As always, any questions are welcome down in the comments or over in the discord. I’ll be happy to help!
DISCORD
Feel free check out my discord server ‘Gnomeland’ for scripting help and general chat
MUSIC
“Danger Storm” Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
15.08.2023
You are not teaching how to script the animation.
I LOVE that you made it from scratch unlike alvenblox he might be spending more time orginizing models then actually scripting LOL
can I add the pathfinding destenation hooked to the players HumanoidRootPart?
I made a bot that just orbets a giant box 10/10 game right there
why is animation glitching so badly? im facing same issue do somebody know how to fix it?
me: well, i put everything, humanoid, now it's gonna be working!
wait, why did it have a error
humanoid variable: are u stupid? you put my name as human
TYSM I made a smart bot that walks around stuff not into stuff 🙂
This man, or should I say gnome, got 70k+ in 2 years from 1k . . .
I love you THANKS SO MUCH, im sub now. But something don't work
4:25
8:54
Code for this episode:
local monster = script.Parent
local humanoid = monster.Humanoid
local PathfindingService = game:GetService("PathfindingService")
local function getPath(destination)
local pathParams = {
["AgentHeight"] = 10.214,
["AgentRadius"] = 0.714,
["AgentCanJump"] = true
}
local path = PathfindingService:CreatePath(pathParams)
path:ComputeAsync(monster.HumanoidRootPart.Position, destination.Position)
return path
end
local function walkTo(destination)
local path = getPath(destination)
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
local function patrol()
local waypoints = game.Workspace.waypoints:GetChildren()
local randonNum = math.random(1, #waypoints)
walkTo(waypoints[randonNum])
end
while wait(0.1) do
patrol()
end
Hope this helps and makes it so you wont be crying when there's an error!
nice one thousand subscribers
Hey I’m making a game about the Roblox dummy like a rig just a rig and it’s gonna be power fighting
i seem to be unable to get the code to run, and im not doing anything wrong.. or i think im not..
i need a lil bit of help
should i not ask this here tho?
How do we pull up the code menu?
Great job! But can we get the model?
Help me please! My npc goes to first part and stop! There is code:
local Steve = script.Parent
local humanoid = Steve.Steve_h
local PathfindingService = game:GetService("PathfindingService")
local function getPath(idet)
local path = PathfindingService:CreatePath()
path:ComputeAsync(Steve.HumanoidRootPart.Position, workspace.idet.Position)
return path
end
local function walkTo(idet)
local path = getPath(idet)
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
while true do
walkTo(workspace.idet)
walkTo(workspace.idet2)
end
mine doesnt work after i put in the first function i and my npc just stopped moving at all animations still playing and it also keeps saying errortype please help me
I can’t get the animation working and I don’t know what script you used to get that to work
My pathfinding thing isn’t working. Help!
Pls pls help my it is saying that Position is not a valid member of vector3 pls help gnomecode
my monster is'nt working i typed in the script but it did not work
This game is a copy of piggy
Hi! I have played teddy and I find it a super fun game. I Was questioning: In chapter 5 can you make a skin quest? U don't need to tho xD
yess it work i have follow other youtube video and there so many video that didnt work but this video help me !!!
Heres the script its a little bit changed but its mostly the same
local stranger = script.Parent
local humanoid = stranger.Humanoid
local PathfindingService = game:GetService("PathfindingService")
local function getPath(destination)
local pathParams = {
["AgentHeight"] = 6,
["AgentRadius"] = 4,
["AgentCanJump"] = false
}
local path = PathfindingService:CreatePath()
path:ComputeAsync(stranger.HumanoidRootPart.Position, destination.Position, pathParams)
return path
end
local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.Success then
for index, waypoint in pairs(path:GetWaypoints()) do
humanoid:MoveTo(waypoint.Position)
humanoid.MoveToFinished:Wait()
end
end
end
local function patrol()
local waypoints = workspace.waypoints:GetChildren()
local randomNum = math.random(1, #waypoints)
walkTo(waypoints[randomNum])
end
while wait(2) do
patrol()
end
IT WORKING SO GOOD!
Bro, these guys thinking his works are useless… Im gonna say something:"Ya guys are just jealous bc of gnomecode`s programming skills or ya guys are just haters that we fans hate haters".
It is saying on line 14 Position is not a valid member of Vector3
Help please
it so much work thanks to you, gnomecode
Thank you i could use this for my horror game but it takes too long
12:06 saving my spot
im getting this erro GetWayPoints is not a valid member of Path "Instance" what do i do?
My ai doesn't loop 9:49
"The NPC isn't going to be doing any chatting."
Famous last words.
Hey! thanks for your video, I'm having some troubles because on server script this work perfectly but I need to do this pathfollow on local script so im locating my localscript on starterPlayerScripts but the movement of the NPC is too laggy and doesn't work well… You know why or how can I fix this? Thanks in advance!
It’s works only on Teddy or on dummies too?
Help, i decides to put this AI to a Bone Rig or a Skinned Mesh, i mean it does work but it keeps detecting walls as nothing, i tried everything to fix this but nothing worked
dude. thank you so much. so helpful. because of you I can make my dream game. I'll send you the link to my game when its finished.
Hey @GnomeCode, how are you able to make teddy's walk animations work coz mine are not working (same issue with part 1)
i have a problem, my ai isnt updating it's path once i move walls around in game, what is problem?
hey dude love your vids! i kinda need help bcuz my monster is phasing through the ground and not moving
bruh- i was using other tutorials but didnt work including this one but i found the problem and it was that the waypoints werent anchored so they just fell trough the baseplate and finally i anchored them and it worked again
path finding script did not work sadly
uh, i got an issue
apparently whenever i try to test the ai, it just says "Position Is Not a Valid member of Vector3."
what do i do when that happens?
The script is not working, when I make the pathfinding script it does not work.
This is for me not you 9:29
after i added pathfinding , it dont work
tip (you can just duplicate animate in starterCharacterScript Then Just change local addhere = script.Parent to local addhere = workspace.AddHere )