generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: pathfinding-related question

Previous Thread :: Next Thread 
fixylol is not online. 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 is not online. 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 is not online. 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
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
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 is not online. 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
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image