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