Is it possible use the path finding service and make it so when a player shoots at the NPC the NPC will get to the closest piece of cover it can find and hide behind it and wait until it has a chance to shoot back? I've been searching for this answer for ages and my last conclusion was scripting helpers.
An Example:
Lets say, your doing a mission going down a "Space Ship" and you spot an enemy and they spot you to, the first thing I want to make that enemy do is get to cover and find the right times to shoot back at that player.
I'm not aware of anything related to the PFS which will do this for you.
I would recommend just activating a .Changed event on the AI's humanoid to see when they are shot at or hurt and then search for the closest area of cover. You can do this by naming all parts in Workspace that can be used as cover something specific and then simply use magnitude to find out which one is the closest and navigate to it using PFS. Here's an example.
function findCover() local ClosestDistance = 10000000 local ClosestObject for _,a in pairs(workspace:GetChildren()) do if (a.Name == 'Cover') then local dis = (robot.Torso.Position - a.Position).magnitude if (dis < ClosestDistance) then ClosestObject = a ClosestDistance = dis end end end return ClosestObject end robot.Humanoid.Changed:Connect(function(prop) if (prop == 'Health') then local cover = findCover() -- get to the chopper!! end end)
Of course, you'll need to include a check to determine when combat is over or the threat is gone and then proceed as normally.