fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 11:54 AM |
how do i make a player stop following a path and start following a new one?
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
Warlyx
|
  |
| Joined: 08 Feb 2016 |
| Total Posts: 120 |
|
|
| 19 Feb 2016 11:57 AM |
paths = {pathcoordinate,pathcoordinate}
table.remove(paths,1)
That would be good I think, and you could do like
while wait() do
if n ~= 10 then n = n + 1 elseif n == 10 then remove end
end
________________________________________________________________________ |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 12:13 PM |
what is "n"?
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2016 12:17 PM |
A lot isn't a number.
On a more serious point, how are moving the player?? Post the code, and I'll tell what to do |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 12:19 PM |
here is the pathfinding part:
function FindPath(pos) local start = script.Parent.Torso.Position local path = paths:ComputeSmoothPathAsync(start,pos,100) if path.Status == Enum.PathStatus.FailStartNotEmpty then warn("Path finding failed: FailStartNotEmpty") return elseif path.Status == Enum.PathStatus.FailFinishNotEmpty then warn("Path finding failed: FailFinishNotEmpty") return end return path:GetPointCoordinates() end
while true do wait(0.1) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then local points = FindPath(target.Position) for _,p in pairs(points) do script.Parent.Zombie:MoveTo(p) repeat distance = (p - script.Parent.Torso.Position).magnitude wait() until distance < 3 end end end
"pos" is defined earlier in the script
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2016 12:26 PM |
Don't use a while true do loop, use RenderStepped for a start. This allows you to do more than one continuous loop in a script, but also makes it easier to break out of.
path = false findingPath = false
function findPath() end
function checkPath() -- Checks it, to see if it should continue end
function move() if checkPath then end end
game:GetService'RunService'.RenderStepped:connect(function() if path and not finding path then end end) |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 12:33 PM |
you just gave me a bunch of variables and functions and didnt tell me what to do with them :/
i'm a noob at path finding
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 12:42 PM |
halp
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 01:34 PM |
bump
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
fixylol
|
  |
| Joined: 14 Dec 2012 |
| Total Posts: 7412 |
|
|
| 19 Feb 2016 02:05 PM |
bomp
Number of times opinion has changed: A lot. |
|
|
| Report Abuse |
|
|
|
| 19 Feb 2016 04:03 PM |
I was AFK
path = false pathPoints findingPath = false
function findPath() findingPath true --Find path if path then path = true pathPoints = pathPoints move() end findPath = false end
function checkPath() -- Checks it, to see if it should continue end
function move() local check = checkPath() if check then else path = false pathPoints = nil end end
game:GetService'RunService'.RenderStepped:connect(function() if not path and not finding path then findPath() end end)
|
|
|
| Report Abuse |
|
|