#[kind of fixed] How do I get blockcasting to work for the player to pathfind off ledges (a*)
1 messages · Page 1 of 1 (latest)
why is main() recursive?
cus if the point isnt valid we find the nearest point and recalculate after reaching it
yeah but why recursive, use a while loop instead?
pretty sure recursive will stack overflow eventually
function movePath(g, p)
local ctrls = require(lp.PlayerScripts.PlayerModule):GetControls() -- for some reason the player cant jump correctly with controls enabled
ctrls:Disable()
for i = 1, #p - 1 do
local tp = g[p[i+1]].pos
hum:MoveTo(tp + v3(0, 0.5, 0))
hum.MoveToFinished:Wait()
end
ctrls:Enable()
end```
movetofinished is a newb trap, biggest problem for this code is it times out after 8 seconds and has a reachedDestination parameter you're not using but you're cooking a custom a* algorithm here so i dont think thats going to be a problem this time since you build a similar output to pathfindingservice
mkay mkay mkay
thank u tho bruddah
i havent had any issues with it so far so i just kept using it LMFAO
what is meetpoint?
so like i create two paths from the player and from the goal and the two just tries calculating to a middle point to connect the two
that's probably why it's walking through walls?
probabblyyyy but thats there the blockcasting comes into play
though both of them use blockcasting not just one path
when your a* returns valid value lua local p, fromStart, closedStart = biAStar(g, si, gi) if p then movePath(g, p)
it calls this function return reconstructPath(fromStart, fromGoal, meetPoint) -> ```lua
function reconstructPath(fromStart, fromGoal, meet)
local path = {meet}
local curr = meet -- add path from start to meeting (reverse)
while fromStart[curr] do
curr = fromStart[curr]
table.insert(path, 1, curr) -- insert at beginning
end
curr = meet -- add path from meeting point to goal
while fromGoal[curr] do
curr = fromGoal[curr]
tins(path, curr) -- append to end
end
return path
end```
looks like it's an id? but if its an id, why is it in the path?
its because its alot more efficient to use ids instead of ykyk you can very easily access ids, and some guy a while ago told me that was the way to go and i just went on with it from there
i'm just going with the flow man 😭
and i've been on this blockcasting bologna for the past week or so
its just cheaper to store ids than vector3 objects
i dont think its in your blockcasting, but just to rule it out, use filterparams:AddToFilter(char) instead of params.FilterDescendantsInstances = {char}
mkay i'll do that rq and i'll be back with you in a min
but see if that ray was hitting the character, or anything immediately stopping your character, then it probably wouldn't pathfind at all
so i really dont think it's your raycast, i think your path may be wrong. maybe add in some debug parts so you can see where all the waypoints are?
do be sure to .cancollide=false and .canquery=false so they dont hit rays or the npc
yasyayaya dwdw
ive had ALOT of problems in the past from just accidentally forgetting that 😭
i'll show you the details in a bit mr man
why aren't you using pathfindingservice?
sometimes the pathfindingservice is dumb and i got fed up with it and decided to do all this
well i can tell you this is good learning experience, but i can also guarantee you pathfindingservice will be better than anything you could hope to create yourself
any issues you encountered are skill issue
this page explains how to use pathfindingservice correctly https://create.roblox.com/docs/characters/pathfinding
it's very, very rare that you actually need to make your own for something pathfindingservice cannot already do, but even in those cases, you'd need to use a navmesh, not the nodegraph you have created.
or if you're going to roll with a nodegraph, use a proper nodegraph instead of a giant 1x1x1 grid
MAYBE A SKILL ISSUE BUT I AM TRYING ALAS
yes its mainly just a learning type experience
oh you said pathfinding through parts, i saw in the title off the edge of a part but that is much less of a problem
LMFAO
SORRY I OUTPUTTED THAT WRONG
when i DID fix it
i went back to the original set after it didnt work i meant 😭
this doesn't appear to do anything since the distance between any 2 cells on your grid are guaranteed to be less than both md and sh lua if dy > 0 then -- moving from higher to lower (dropping down) canConnect = hdif <= md -- dropping - use drop limit else canConnect = hdif <= sh -- stepping - use step limit end
oh god main is in a while loop, i somehow overlooked that lua function main() local tgt = workspace:WaitForChild("target") while true do local g, gridMap = genGrid() connNb(g, gridMap)
nonoo i just added that in with the adjustment 😭
o nvm it changed
your gridsize is too small for the smallest dropsize lua local gridSize = 150 -- gridSize: total size of the navigation grid local md = 100 -- maxDrop: maximum height a character can drop down
since the grid is centered around the player (therefore radius is 75 studs) and the maximum drop height is 100 studs (greater than 75), and that does look like a long fall. i dont think its 75 studs but y'know, have to check everything
tbh you should probably just use pathfindingservice or hire someone coz this is not trivial code
you got a lot more debugging to do if you want to continue with this 
i suggest adding more visualization, debugging, maybe temporarily disable the step height etc
i'm too limited to help you further without properly running and testing this code
and ngl i highly doubt many people here are able to, or (those who can) have the time to help you with this
RAHHHHH
dw mannn
I'll figure it out eventually 😭
i belief in you 
i'll scream like a girl when this day happens 🫡
could you show or explain an example of this
because i only know how to do grids 😭
also for edge thang i figure to just have the blockcast ignore nodes that goes down relative to the player as a simple bandaid fix
[kind of fixed] How do I get blockcasting to work for the player to pathfind off ledges (a*)
** You are now Level 8! **
a proper nodegraph would be where you manually place walkable nodes and their connections so instead of scanning a colossal grid, you're instead searching through a much smaller number of nodes which are manually connected to each other, it will make your pathfinding substantially faster. you can improve this further by turning it into a navmesh
ohhhhhhhh
mkay, well it's pretty fast let alone, just with a very small freeze before going
you could throw it in the local player and create a part in the workspace (naming it target) and it'll pathfind to it, it can walk up slopes, down slopes, cant jump yet but i got an idea with how i'll do it