I am making a soccer game, and right now I am working on the goal keepers and my goal for them is they would be NPCs that would stay in the goal and just move to stay in between the ball and the goal, and if the player with the ball gets close to the goal the goalie would come out. I know there are some tutorials on how to make an NPC follow a player but this is a little different so I was just wondering if any of you might have some idea on where I would start.
1 Like
You should also use PathfindingService AI for sure and make waypoints to your part.
For example:
local PathfindingService = game:GetService("PathfindingService")
local dummy = workspace.Dummy
local Humanoid = dummy.Humanoid
local endDestination = workspace.endDestination
local Path = PathfindingService:CreatePath()
Path:ComputeAsync(dummy.HumanoidRootPart.Position, workspace.lolNo.Position)
if Path.Status == Enum.PathStatus.Success then
local hm = Path:GetWaypoints()
for i,v in pairs(hm) do
local hmm = Instance.new('Part',workspace)
hmm.Size = Vector3.new(1,1,1)
hmm.Position = v.Position
hmm.Anchored = true
hmm.CanCollide = false
Humanoid:MoveTo(v.Position)
end
end
But to be sure if it’s works gonna do it by myself and will update you about something.
3 Likes