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 efficiency

Previous Thread :: Next Thread 
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 07:31 PM
This is how my pathfinding script works

while wait(5) do -- changeable number

-- Get TargetsPosition, and the position of the target last time

if TargetsPosition ~- LastPos then
-- Pathfind
end

end

With a lot of AI's doing this in game, I'm guessing this would lag. It will redo the path if the position isn't the exact same. Is there a more efficient way to improve any part of this process?
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 07:35 PM
Mainly if you've used Pathfinding before and have any tips I'd appreciate them
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 07:36 PM
You could call it whenever either the target's position changes or when your path gets obstructed, instead of a loop.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 07:39 PM
Doing it whenever the targets position changes would cause a ton of lag. It'd recalculate the path 30 times a second.

The path probably won't be obstructed. But, is there a way to detect that
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 07:45 PM
Are you using the pathfinding service? I haven't really worked a lot with it but I'd look into CheckOcclusionAsync.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 07:47 PM
Okay I'll put that in. But we still have the main problem.

Running it everytime the targets position changes would make it trigger 30 times a second, and I don't like using loops.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 07:53 PM
CheckOcclusionAsync wouldn't work, just because it doesn't check if the Target has moved from the Endpoint. It just checks if the path was blocked.
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 07:57 PM
You could do something like

target.Changed:connect(function()
if (target-endpoint).magnitude > 5 then
--do stuff
end
end)
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 09:03 PM
How do I get CheckOcclusion to work?

if Path:CheckOcclusionAsync(0)then

end

If you understood the description,
http://wiki.roblox.com/index.php?title=API:Class/Path/CheckOcclusionAsync
How do I check if the path is blocked?
Report Abuse
Ictis is not online. Ictis
Joined: 01 Sep 2011
Total Posts: 1216
25 Jun 2015 09:14 PM
occlude = Path:CheckOcclusionAsync(0)
if Path:CheckOcclusionAsync(0) ~= -1 then
--occlude is the point which is blocked.
end
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 09:42 PM
What number should I put in the argument?

if Path:CheckOcclusionAsync(0) ~= -1 then
-- This goes through if there is a path
end
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
25 Jun 2015 09:43 PM
Iterate through the path points and use their index as the number to check to see if that point is occluded.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
25 Jun 2015 10:01 PM
would this work

if Path:CheckOcclusionAsync(i) ~= -1 then
print'No path, Recalculating...'
end
Report Abuse
Cuyler is not online. Cuyler
Joined: 27 Feb 2006
Total Posts: 3784
25 Jun 2015 10:19 PM
It should, as long as i is a valid index number in the table.
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
26 Jun 2015 02:04 PM
for i, point in pairs (points) do

for p, point in pairs (points) do
if Path:CheckOcclusionAsync(p)==-1 then
print'No path'
end
end

-- Move to

end

It goes through ever point and moves to that point. Before it moves, it will check through all the points to make sure the path is still unblocked.

output:
Start point is invalid
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
26 Jun 2015 02:27 PM
CheckOcclusion Just won't work. Prints wrong each time.

if Path:CheckOcclusionAsync(1) == -1 then
print'Path'
else
Recalculate = true
print'No path'
end
Report Abuse
AntiFiter is not online. AntiFiter
Joined: 14 May 2009
Total Posts: 12290
26 Jun 2015 02:50 PM
For someone who understands how to use CheckOcclusionAsync, can I see a working example of how to check if anything in the path is blocked:

for i, point in pairs (points) do

-- CheckOcclusionAsync Here

-- MoveTo
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