Roblox Studio AI Pathfinding Tutorial || Part 2 - Walk Animation

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

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

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

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

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

      -- NPC Pathfinding Script (Server-Side) -- Place in NPC
      local PathfindingService = game:GetService("PathfindingService")
      local npc = script.Parent
      local humanoid = npc:WaitForChild("Humanoid")
      local humanoidRootPart = npc:WaitForChild("HumanoidRootPart")
      local destination = workspace.Target
      -- Reference the Animate script
      local animateScript = npc:WaitForChild("Animate")
      -- Access the built-in walk animation
      local walkAnimationTrack = humanoid:LoadAnimation(animateScript.walk.WalkAnim)
      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(humanoidRootPart.Position, targetPosition.Position)
      -- Check if the path was successfully computed
      if path.Status == Enum.PathStatus.Success then
      local waypoints = path:GetWaypoints()
      -- Play walk animation when NPC starts moving
      walkAnimationTrack:Play()
      -- Move the NPC along the waypoints
      for _, waypoint in ipairs(waypoints) do
      humanoid:MoveTo(waypoint.Position)
      humanoid.MoveToFinished:Wait()
      end
      -- Stop the walk animation when NPC reaches the destination
      walkAnimationTrack:Stop()
      else
      print("No path found!")
      end
      end
      moveToTarget(destination)

    • @path-u1y
      @path-u1y 3 หลายเดือนก่อน

      could you make a enemy attacking ai, but instead of just scripting it explain how it works

  • @이세빈좋아
    @이세빈좋아 3 หลายเดือนก่อน +1

    감사합니다