This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.
You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to stop the rock monster in my game from getting stuck on corners.
I am wondering whether I am using Roblox’s pathfinding system appropriately or if I am doing something wrong that is causing it to have these problems.
- What is the issue? Include screenshots / videos if possible!
Also, here is the script I am using, which is being fired every frame via heartbeat service:
--should path to the player
local function pathTo(sentinelPos, playerPos)
local path = game:GetService("PathfindingService"):CreatePath({
AgentRadius = 6,
AgentHeight = 12.5,
AgentCanJump = false,
AgentCanClimb = false,
WaypointSpacing = 6
})
local success, errorMessage = pcall(function()
path:ComputeAsync(sentinelPos, playerPos)
end)
if success then
local waypoints = path:GetWaypoints()
for i = 1, table.maxn(waypoints), 1 do
sentinel.Humanoid:MoveTo(waypoints[i].Position)
sentinel.Humanoid.MoveToFinished:Wait()
end
end
end
This is a custom rig which I built using Arch Mages “Rig Edit Lite” plugin, not sure if this would interfere with Roblox’s pathfinding system.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried setting the agent radius to a lot of different values; I did measure this agent radius it is correct.
I have tried firing the path finding less than every single frame, which did not really change the result.
I made my own pathfinding system that was extremely flawed and I am hoping to move back to the roblox pathfinding system as I believe I am just misinterpreting its functionality.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
One important thing I have noticed is that it seems to get a path that works great, then as it is navigating that path it begins to take shortcuts that should not be allowed according to the parameters I have given it. I am trying to keep the pathfinding as simple as possible; I do not care if the rock monster turns a corner in a non-smooth manerism. I just really, really want it to stop getting caught on corners.
I have heard about A* (A times or A star) pathfinding, but I am not sure whether I can use this in roblox, since I read lua is too slow to make its own grid for pathfinding. I am also fairly sure this is not a 3D solution, and I would like it to be, though it does not absolutely have to be 3D if the pathfidning is high enough quality (doesn’t get caught on corners).
Any help with this is sincerely appreciated as this is the last major obstacle to developing my game, I am really really stuck here, and I am so grateful for anyone who can help me out here.
REALLY IMPORTANT NOTES:
-
I was not referencing the feet of the player and the rock monster which is necessary for pathfinding as the ComputeAsync expects the point at the humanoid at ground level.
-
Setting the humanoid to can collide and USING HIP HEIGHT was something which I was not doing which was causing the rock monster to get caught on ramps and other objects.
-
Every other part in the rig should have can collide disabled, if you want your monster to still physically interact with players im fairly sure you can use collision groups.
In summary, I made a lot of mistakes regarding how I used the pathfinding. I recommend using axolotl’s solution and slender bandits solution in combination with the hip height thing that I wasn’t doing. Use the feet position of the humanoids by getting the root part position and subtracting the hip height from the Y Value of the root parts position. All of these things should durastically improve the humanoids ability to navigate and pathfind!