EZ Pathfinding V3 [OUTDATED]

In your post you made valid points however as I have said numerous times, you may change it around and what I provided was just an example and wasn’t meant to actually be used. Apologies if I didn’t make the example clear on its purpose.

Is it possible to create a script that creates a path finder, then recalculates another path before the next path is completed so that it can (re)direct to moving objects?

Yes this is possible with enough scripting. The script would include ray casting to check for an object, the stop function after the object is close, and finally creating and running a new path avoiding any obstacles.

Lately I decided to make a EZ Pathfinding V4 which will be released soon. That means that EZ Pathfinding V3 (this module) will be discontinued and won’t receive updates by me. It will still be useable however when the new module comes out, I suggest switching to it as it incorporates OOP and makes using the module a whole lot easier. Thanks to all my supporters, this couldn’t have been done without you guys!

Message me with what features you want to be added to V4.

1 Like

As path finding has a chance to fail, how would we handle possible failures? Would it throw an error that we would need to catch or would it just return a nil path?

I would pcall the new function and then check if the path was successfully created. If not, junk that path and create a new one. I won’t be updating this anymore because of a newer version coming soon.

1 Like

Love the module, just nitpicking but .Magnitude can me expensive if used often. In the function findNearestTorso:

	local list = game.Workspace:GetChildren()
	local torso = nil

	local temp = nil
	local human = nil
	local temp2 = nil
	
	for i = 1, #list do
		temp2 = list[i]
		if temp2.ClassName == "Model" then
			if temp2 ~= npc then
			temp = temp2:FindFirstChild("HumanoidRootPart")
			human = temp2:FindFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
				if (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
					end
					end
			end
		end
	end
	return torso

You should set the magnitude to a variable so you dont have to do that operation twice like this:

	local list = game.Workspace:GetChildren()
	local torso = nil

	local temp = nil
	local human = nil
	local temp2 = nil
	
	for i = 1, #list do
		temp2 = list[i]
		if temp2.ClassName == "Model" then
			if temp2 ~= npc then
			temp = temp2:FindFirstChild("HumanoidRootPart")
			human = temp2:FindFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
               local mag = (temp.Position - pos).magnitude
				if mag  < dist then
					torso = temp
					dist = mag 
					end
			end
			end
		end
	end
	return torso

Yeah, that could be a personal change. I’ve already stated that I will be no longer updating this due to a sequel to this module coming out soon. That module will include better practices and will incorporate OOP.

2 Likes

EZ Pathfinding Pro was recently released. I suggest transferring over to that if you are currently using this. This module is now outdated and won’t be updated anymore.