I’m seeing some GC being created quite frequently (40 bytes, every few frames in my game) by Path.Reset() in Path.cs.
It’s due to this line: nnConstraint = PathNNConstraint.Default;
Is it possible to improve the script to avoid that alloc?
I’m seeing some GC being created quite frequently (40 bytes, every few frames in my game) by Path.Reset() in Path.cs.
It’s due to this line: nnConstraint = PathNNConstraint.Default;
Is it possible to improve the script to avoid that alloc?
I have wanted to do that, yes. However, due to backwards compatibility it is not so trivial.
Hey aron - just curious if there is any progress here?
Hey @aron_granberg any ideas on how this one can be resolved? We tried a few solutions but it broke pathfinding significantly.
Hi
If you never modify the NNConstraint (which includes not using seeker->traversable tags or traversable graphs) then you can create a new static field:
static readonly NNConstraint NNConstraintDefault = NNConstraint.Default;
and then change that line to
nnConstraint = NNNConstraintDefault;
If it’s just 40 bytes every few frames, I would not worry in the slightest, though. That’s a tiny amount of garbage in the greater scheme of things.