#pathfinding latency
1 messages ยท Page 1 of 1 (latest)
can you
uh
send the function Pathfinding.GetLowestFCostPathNode()
and FindPath()
thank for you taking the time
here it is https://pastebin.com/1509jzkW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ok what is openlist
also to catch you up to speed
in case you dont know how to read the call stack
uh getting the length of the list is taking forever
yeah! im not sure why it takes so long when its a native array
what is the length of the list?
unity froze for like 1min trying to print
44 max length i saw but its an array per path finding request
44 * x(number of paths) * y (number of possible move positions)
uh
why does it print so many times
how many times do you call GetLowestFCostPathNode
ill just abbreviate to GLFC
ok
it calls it 1000+ times
so im pretty sure becuase..
enemy units have like 8 or more possible move locations right, so for each move location i find a path to each location
but i think the numbers are too high for that
weirdly the atomic call isnt a blocking one so it shouldnt take very long
its checks the handle
im not sure what that consists of tho
per frame right
dont forget the profile is per frame because that info provides a lot of context
per frame..
that seems even more wrong now
hmm then again...
well that 3k ms might just be on one specific frame
no clue how often you are running this
its on button click tho right
yeah
so it would just be one frame
i can link a vid?
so there isn't too much delay here bcause the number of units is reduced
but you can kinda see it when i press end turn or complete a move action with the player unit
very similar to what i linked
just reduced
at the end of every action and turn all the enemy units revaluate what action they should do and where they should do it
same functions
namely the atomic one is interesting
did you figure anything out
not really tbh, i dont understand why it uses that method on the backend when its a native array
yeah it doesnt use the job system though?
You typically do not need to use this type in your code unless you are implementing your own NativeContainer type.
so it is related to Native containers
im not actually sure what a native container is
NativeArray<PathNode> pathNodeArray = new NativeArray<PathNode>(_cells.Count, Allocator.Temp); oh shit...
maybe this?
NativeArray<int2> neighbourOffsetArray = new NativeArray<int2>(8, Allocator.Temp); other containers are just simple types
does that call getlength tho
ahh no it doesnt
because it is VERY specifcally
this
step one
it has to be under GLFC
step two
it has to call getlength
thats where you performance is going
private int GetLowestFCostPathNode(NativeList<int> openList, NativeArray<PathNode> pathNodeArray)
{
PathNode lowestCostPathNode = pathNodeArray[openList[0]];
for (int i = 1; i < openList.Length; i++)
{
PathNode testPathNode = pathNodeArray[openList[i]];
if (testPathNode.fCost < lowestCostPathNode.fCost)
{
lowestCostPathNode = testPathNode;
}
}
return lowestCostPathNode.index;
}
doesnt call it though
and get_length is taking 83.3% of the frame
i wonder if i can just get the length once or something.. but that doesnt work cause of the nature of using the open list pattern i think
oh shit you know i just saw this cool tab
calls
very cool
so GLFC gets called 1.3k times
and getlength 52.4k
yeah crazy
i dont think calling get length 52k times is right
im trying to work out the math
bah maybe that is right
yeah i tink so as well
and it called 52389
times
so if you start at i=0 it should be 52390
well
no
since you run the loop multiple times
yeah ^ exactly
yep
๐
im a bit stuck, thanks for taking the time to understand the issue, no stress if you have no advice for me
btw
what are those small spikes in frametime'
the ones a few hundred frames before the big spikes
like that
oh
i think just creating the unit or instantiating something like the projectile
i dont have pooling or anyhting yet
its not dots
like creating a bunch of gameibjects at once
and disabling and enabling them as required
not important for this pathfinding though
hahah yeah
fuck this is annnoying me so much, i need to fix this before moving on, i hate leaving it like this
this isn't really 3d
is it?
it's a 2d movement grid
there's a lot going on here
and you have written a lot of code
and you are using nativearray for some reason
your profiler is telling you that you are using the nativearray api wrong
but it also looks like you're deep profiling
which doesn't mean what you think it means
you're at the start of a long journey
there are 52k calls, but there are only maybe 400 spots that need to be checked
so this is a huge bug
what is your goal?
to have a working game?
haha yes the goal is to have a working game
yes pathfinding is only in 2d because we don't have cells underneath the cells on a higher level so we can get away wth it
are there 400 spots?
the profiler is showingl ike 5-8 units all checking for a location to move to
not just 1
i see what youre saying but i duno how to debug it further
@pearl python
8*400 = 3,200, still much less than 52,000