Forum rules - please read before posting.

Performance hiccup when naving in 2D?

edited October 2014 in Engine development
So I've been noticing a bit of a performance hiccup when clicking around the scene to move my 2d character and while I thought it was a one off, I started noticing it's actually happening all the time (in the deployed game too).

Luckily I have managed to identify the exact conditions when it happens and it's basically whenever the navigation path is not a direct line.

If there's a straight line that connects where your character is and where you've clicked, this stutter won't happen.

If however the path is composed of 2 or more edges then you get a very noticeable stutter (~0.5second) during the pathfinding.

Has anyone else experienced this, is it a known issue and are there any workarounds?

FYI I am using what I believe is the standard 2d workflow at the moment (so basically, Unity sprites, XY plane and 2d polygon collider for my navmesh)

Thanks!

Comments

  • On what platform are you testing on?  The polygon pathfinding algorithm is Dijkstra's, which is one of the fastest, but it's recommended to keep your NavMesh as simple as possible.  How many vertices does it comprise of?
  • I also experience this. Haven't noticed it as much in a platform-build  but in the editor/player I find it skips a few frames and jumps to catch up.

    I had assumed it's because I'm running Photoshop and Maya along side Unity - even on an 8 Core Xeon Workstation with 28GB of RAM as Unity is only 32bit. That and also that I'm running in the editor presently.


  • My navmesh has 76 vertices and it has a "hole" mesh in it too with 7 vertices.

    Xidore I seem to get this in both Webplayer and PC builds too so it's definitely not an editor only issue.
  • I just added a bunch of vertices to a navmesh (with 11 vertices) in my scene that works well performance-wise, raising it to 57 and immediately got the behaviour you describe.
  • Very interesting! Cheers for the extra data...I'll keep investigating. And I'll see if I can simplify my navmesh (although I wouldn't have thought 76 verts is that many)
  • Yeah I think I had too many vertices in too many nav mesh holes.

    Would be good to know the nascent ceiling on what will affect performance - and whether its platform sensitive too.
  • I'd imagine it's tied to the specs of your machine.  57 isn't much, it's true, but the algorithm involves a matrix of that width, so you're actually dealing with 57x57=3,249 variables.
  • What are the implications of the various Raycast settings in relation to performance?
    I have mine set to:

    Navmesh ray len= 100
    Hotspot ray len= 100
    Moveable ray len = 30

    I can't even recall whether these are the defaults.
  • Honestly, I'm not too sure.  Reducing them to their minimum required should certainly give a boost, but of how much I can't say.  They're literally referring to how far away Hotspots / NavMeshes etc can be from the camera and still be detected.
  • Oh, in that case 100 seems quite large if its in units. My (2D) scene's NavMesh area is around about 45 units wide by about 10 tall.

    I'll give it an experiment and see.
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.