Roblox Studio AI Pathfinding Tutorial || Part 1 - Movement and Obstacle Avoidance

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 4

  • @duckhive-games
    @duckhive-games  3 หลายเดือนก่อน

    Project File (FREE) Here:
    www.patreon.com/posts/roblox-studio-ai-111712034?Link&

    • @duckhive-games
      @duckhive-games  3 หลายเดือนก่อน

      -- NPC Pathfinding Script (Server-Side) -- Place in NPC
      local PathfindingService = game:GetService("PathfindingService")
      local npc = script.Parent
      local destination = workspace.Target
      local function moveToTarget(targetPosition)
      -- Create a path to the target
      local path = PathfindingService:CreatePath({
      AgentRadius = 2,
      AgentHeight = 1,
      AgentCanJump = true,
      AgentJumpHeight = 5,
      AgentMaxSlope = 45
      })
      -- Compute the path to the target
      path:ComputeAsync(npc.HumanoidRootPart.Position, targetPosition.Position)
      -- Check if the path was successfully computed
      if path.Status == Enum.PathStatus.Success then
      local waypoints = path:GetWaypoints()
      -- Move the NPC along the waypoints
      for _, waypoint in ipairs(waypoints) do
      npc.Humanoid:MoveTo(waypoint.Position)
      npc.Humanoid.MoveToFinished:Wait()
      end
      else
      print("No path found!")
      end
      end
      moveToTarget(destination)

  • @QelithRequiem
    @QelithRequiem วันที่ผ่านมา

    thanks man ...found your video ....really what i was looking for all this time ;D