Hi everyone, just started using GDevelop recently and I tried searching forums + documentation so apologies if I missed something, but is there anything in particular that would cause strange visual glitches for a pathfinding object, when using virtual cell height smaller than 20?
Or perhaps I’m just misunderstanding how this is meant to be used.
I’m trying to use it for a point and click game with a smooth transition instead of visually seeing the step-like behaviour, but when I set it to anything less than 20 to smooth it out, strange behaviour starts happening, like sprite splits off into three phantom sprites at random intervals etc…
Thanks for any help!
If you’re just trying to move things from place to place (or need any other smooth transitions like scale, width/height, etc) then you should be using tweens rather than pathfinding (this should also boost performance as it shouldn’t be computing paths).
Here’s the wiki page: Tween Wiki Page
Here’s an example project where you can check the code and test in the preview: Tween Test
If this ain’t what you’re looking for or need help please follow up!
Thanks for the info! So in this case the character will sometimes be navigating around obstacles. I also have keyboard and gamepad support for manual control, but looking to use pathfinding in this case to move around items.
Funny thing is that when I started, the movement was smooth and then later after adding keyboard and gamepad support, things seemed a little off.
I even duplicated the scene and stripped everything out except a few lines of condition/action, but the issue persists, perhaps there is something I’m missing somewhere.
Although I supposed I could simplify the pathfinding by tweening between predefined areas for the player to walk to
Does everything work smoothly without them? (instead of deleting try disabling them by selecting the events and pressing “d” on the keyboard) If so, could you provide your keyboard / gamepad events? Something there might be causing the issue.
Thanks for the suggestion, I had tried disabling, before duplicating and then testing a stripped down version.
Tonight I created a new project and tested with only 1 action, detect mouse and then move object to position and the judder was there, so I must have been mistaken that it was originally smoother.
I’ll just stick with the current setup.
I do find it strange that it becomes unstable when using values under 18 though for the virtual cell height, but perhaps that is based on size of game screen and objects.
Anything below that, the pathfinding is all whacky and ghost objects get duplicated/flung across the screen.
So to summarize, thanks again for your support and everything seems in order for the time being!
I think I actually may have found the reason for the jitteriness that may occur. From my own tests, it mostly occurs near the end of the travel. If this is true for you, check the dropdown below for why it might happen and why smaller cell sizes cause the problem.
Why happen jitter sometime?
Basically, the pathfinding follows the lines created by a grid. It has to reach a point where the gridlines intersect, and cannot just go somewhere smoothly. The grid size is defined by you through the
virtual cell width and
virtual cell height values. Therefore, the smaller the grid (cell) size, the more accurate the movement, but you get more jitter. The bigger the grid (cell) size, the less accurate the movement is, but you get less jitter.
Here are 2 examples to explain what I’m saying:
In this one, the cell width/height are 10. See how much it jitters?
In this one, the cell width/height are 40. Jitters much less, right?
Ah, yes, that seems to be exactly it, thanks for clarifying!