is this a normal issue because this is pissing me off and i know when my game releases people will bug report this, any fix to this by adding costs or something?
Well that depends on what pathfinding algorithm your using. A* algorithm or whatever, you need to provide a script because there are many types of pathfinding. If your talking about simple pathfinding like a simple :moveto , then there is nothing in place in that algorithm to stop going into trees etc
Include your pathfinding script in this question, I can help you if you provide more information, this can be anything from instance tagging to ray casting (:
i’m using simplepath the module, it uses roblox pathfinding, my script is really bad since it was made a while ago and it’s legit embarrasing but well i’ll send it.
local Path = SimplePath.new(Dummy,{
COMPARISON_CHECKS = 5,
AgentRadius = 4,
AgentHeight = 8,
AgentCanJump = false,
WayPointSpacing = 3,
Costs = {
Plastic = -100
}
})
local CurrentGoal = math.random(1,#v:GetChildren())
local StartPos = CurrentGoal
local Goal = v[tostring(CurrentGoal)]
Dummy:SetPrimaryPartCFrame(Goal.CFrame * CFrame.new(4,4,-4))
local Animation = Dummy.Humanoid:LoadAnimation(game.ReplicatedStorage.NPCAnimations.RUN)
Dummy.Humanoid.Running:Connect(function(Speed)
if Speed > 0 and not Animation.IsPlaying then
Animation:Play()
elseif Speed == 0 and Animation.IsPlaying then
Animation:Stop()
end
end)
Dummy:WaitForChild("UpdateSize"):Invoke()
local Paths = {Path.WaypointReached,Path.Error,Path.Blocked}
module:HookEvents(Paths,function()
Path:Run(Goal)
end)
Path.Reached:Connect(function()
CurrentGoal += 1
if CurrentGoal > #v:GetChildren() then
CurrentGoal = 1
end
Goal = v[tostring(CurrentGoal)]
Path:Run(Goal)
end)
Path:Run(Goal)
Nevermind wasn’t as embarrasing as i thought it would be lmao
Can you give me some more information. Is the dummy just walking directly to the trees. Like can you be a bit more specific than it really wants to go into trees please. Like sometimes does it register a tree and go around or never
i have two points that are super linear and the dummy for some reason is determined to go around the tree or just go onto it even tho it’s to the side, it’s like a dummy magnet
There is an updated module here:
https://www.roblox.com/library/6744337775/SimplePath-Pathfinding-Module
The script seems unnecessarily jumbled up and without comments I’m struggling to establish whats going on when there are some references which aren’t in the code.
Code should look something like this:
--Import the module so you can start using it
local ServerStorage = game:GetService("ServerStorage")
local SimplePath = require(ServerStorage.SimplePath)
--Define npc
local Dummy = workspace.Dummy
-- Define a part called "Goal"
local Goal = workspace.Goal
--Create a new Path using the Dummy
local Path = SimplePath.new(Dummy)
--Helps to visualize the path
Path.Visualize = true
--Dummy knows to compute path again if something blocks the path
Path.Blocked:Connect(function()
Path:Run(Goal)
end)
--If the position of Goal changes at the next waypoint, compute path again
Path.WaypointReached:Connect(function()
Path:Run(Goal)
end)
--Dummmy knows to compute path again if an error occurs
Path.Error:Connect(function(errorType)
Path:Run(Goal)
end)
Path:Run(Goal)
that does the same thing lol, it just has the costs and the settings there
I mean that’s what you asked about.
Is there code missing because this refrence means nothing to me in the code
that’s a folder which has all the goals in them, they’re set to be numerical and it works really well unless i have a map around them,
You could use the PathfindingModifiers to control this behavior, throw a box around the trees and boom npcs will no longer want to go into the trees or any other object because you’ve told them not to. And this means less coding for you.
just found that this existed tysm i just added that to all the trees and now they walk trough smoothly
(also ditched simplepath because it’s too unconfigurable)