Forum rules - please read before posting.

Physics2D.OverlapCircleAll

I've noticed some FPS drops every now and then, and I've narrowed them down to basically any pathfinding that involves more than one node. If I click around to walk in an open space, there's no lag whatsoever, but if the character needs to take a turn, then Physics2D.OverlapCircleAll slows things down by a lot:

Every orange spike you can see above is the result of Physics2D.OverlapCircleAll when clicking to walk somewhere that isn't a straight line. Is this inherent to AC's pathfinding, or is it something that can be optimised without breaking it? When I first started using AC many years ago, there were real issues around characters not respecting certain navmesh shapes (cutting corners sometimes, etc), but I haven't encountered those issues in ages. I'm assuming these checks might be part of the solution that prevents that?

Comments

  • Yes, the calls are necessary for the default 2D pathfinding algorithm. How many calls are made will be based on the "Accuracy" slider.

    The alternative 2D algorithm is the A* pathfinding package on the Downloads page. This algortithm avoids the need for such calls.

  • edited April 2023

    Thanks! I'll play with the accuracy slider. Something that isn't clear to me though is how the main pathfinding accuracy setting interacts with the one in the navmesh itself. What is the one in the navmesh supposed to do that the main one doesn't?

    Edit: reducing the main accuracy setting did very little to reduce the FPS drops, but wow, changing the one on the navmesh improved performance significantly. Very good to know.

    Edit 2: just one more observation. I was unable to test the accuracy settings properly with the latest AC version because even with the highest accuracy, the pathfinding is cutting corners through right angles in the navmesh (I believe this is related to the pathfinding issues I reported in the other threads). But if I use a previous version, I can go as low as 0.2 accuracy in the navmesh without being able to reproduce such issues, and the performance cost of a pathfinding update becomes negligible (over 10x less impact than before).

  • What is the one in the navmesh supposed to do that the main one doesn't?

    The Settings Manager's Destination accuracy slider is effectively a measure of "how close is close enough" when it comes to a character moving to a specific position. The higher the value, the closer they'll get to the destination - but overshooting may be possible if their movement speed values are very high.

    You can enable Retro-style movement in a character's Inspector for precise movement, which is particularly intended for pixel-art games. The Manual's "Precision movement" chapter covers this topic in more detail.

    The Navigation Mesh component's Accuracy slider relates to the size of the circle raycasts involved with calculating the path the character takes.

    the pathfinding is cutting corners through right angles in the navmesh (I believe this is related to the pathfinding issues I reported in the other threads).

    That issue specifically is related to the algorithm not correctly placing the start/end positions on the NavMesh. I'll be releasing an update shortly, but if you have a repro of an earlier version, rolling back the two Perform2DRaycast functions in AC's UnityVersionHandler function should fix it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.