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

156 Comments

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  37. tip (you can just duplicate animate in starterCharacterScript Then Just change local addhere = script.Parent to local addhere = workspace.AddHere )

Leave a Reply

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