AI Monster Pathfinding -Teddy Horror Game #2 - godsandmonstersgame.com

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

326 Comments

  1. I'm really enjoying listening to your voice and scripting. Going strong so far with the tutorial. Can I make a game out of this tutorial?

  2. You are not teaching how to script the animation.

  3. I LOVE that you made it from scratch unlike alvenblox he might be spending more time orginizing models then actually scripting LOL

  4. can I add the pathfinding destenation hooked to the players HumanoidRootPart?

  5. I made a bot that just orbets a giant box 10/10 game right there

  6. why is animation glitching so badly? im facing same issue do somebody know how to fix it?

  7. 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

  8. TYSM I made a smart bot that walks around stuff not into stuff 🙂

  9. This man, or should I say gnome, got 70k+ in 2 years from 1k . . .

  10. I love you THANKS SO MUCH, im sub now. But something don't work

  11. 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!

  12. Hey I’m making a game about the Roblox dummy like a rig just a rig and it’s gonna be power fighting

  13. 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?

  14. 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

  15. 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

  16. I can’t get the animation working and I don’t know what script you used to get that to work

  17. My pathfinding thing isn’t working. Help!

  18. Pls pls help my it is saying that Position is not a valid member of vector3 pls help gnomecode

  19. my monster is'nt working i typed in the script but it did not work

  20. 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

  21. yess it work i have follow other youtube video and there so many video that didnt work but this video help me !!!

  22. 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

  23. 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".

  24. It is saying on line 14 Position is not a valid member of Vector3
    Help please

  25. Thank you i could use this for my horror game but it takes too long

  26. im getting this erro GetWayPoints is not a valid member of Path "Instance" what do i do?

  27. "The NPC isn't going to be doing any chatting."
    Famous last words.

  28. 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!

  29. It’s works only on Teddy or on dummies too?

  30. 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

  31. 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.

  32. Hey @GnomeCode, how are you able to make teddy's walk animations work coz mine are not working (same issue with part 1)

  33. i have a problem, my ai isnt updating it's path once i move walls around in game, what is problem?

  34. hey dude love your vids! i kinda need help bcuz my monster is phasing through the ground and not moving

  35. 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

  36. 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?

  37. The script is not working, when I make the pathfinding script it does not work.

Leave a Reply

Your email address will not be published. Required fields are marked *