Major Stutter When Moving After Adding HasPath()

After adding the check for HasPath(), I get major pauses when moving. It seems to happen as the unit moves to a new grid position. If I comment out the call to HasPath in MoveAction, it goes back to normal. I don’t see any difference between my code and the course, but I don’t see any stuttering in the videos. Is this a known performance issue that will be addressed later, or should I spend some time on it now to figure out what’s going on? I’ve seen some other suggestions, like using Dictionary instead of list, but I would expect this to be part of the course if it’s a performance issue.

My grid is only 23x23.

Thanks.

I figured out my issue. I was multiplying the move distance by the cost factor too soon, so I was checking 40 move spaces instead of 4. Had to run a diff with the project code. The implementation is still pretty inefficient, but at least it is playable again.

It is a fairly inefficient setup, to be sure. With small moves, it’s fine, but if you were to try to move say… 40 spaces like you’re seeing here the path search gets pretty brutal.

Good job getting it sorted. Often checking against the repo’s code can show the difference.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms