Haha, I have a (headache) algorithm in mind and wanted to test it out, but I am not sure if it is translatable into Gdevelop events. lets see if it checks out
When mouse is clicked on a point, store that cells location in variables,lets call it ‘Destination X and Y’.
Let Pathfinding calculate the path to ‘Destination’
Using Player.Pathfinding::NextNodeX() and Y() store the location of the next node in the path in variables ‘TempNodeX and Y’
Create a + shaped object at the location of TempNodes X and Y. The + shaped object needs to be at least one pixel larger than the cellsize. So it should be atleast 65x65 if cell size is 64x64. The + shape object must not be larger than the double of cell size.(i.e. shouldn’t be larger than 127 in this case)
There will be two kinds of obstacle (objects) in a scene. One will be a regular wall, the other will be a special corner wall. When the + object is created, it should check if it has collided with a corner wall. Basically we are detecting if there is a corner wall in the cell adjacent to the TempNode. If this is True, Player should stop at TempNode and disable diagonal movement (using Diagonal Movement action in Gdevelop) and then let Pathfinding calculate a new path using linear mode.
6.Keep creating + in next nodes and keep checking for collisions , as long as there is a corner wall around, keep the pathfinding mode to linear and continue on the newly calculated path. When there are no collision with a corner wall, switch back Diagonal Mode ON, then recalculate the path.
7.Keep switching back and forth from diagonal to linear until the destination is reached.
Easier said than done
I’ll TRY to try this, in the meanwhile any suggestions to improve this are welcome. Am I missing something here?
Hey Guys I am back with some success.
I eventually had to give up on the algorithm because it was way out of my league.
So I relied mostly on the tips and tricks provided by you guys gradually building up on it, in the process I now feel much more comfortable with Gdevelop. I now have a better understanding of its working than the day I began working on this problem.
Tweaking up the grid size with a combination of resizing the sprites seems to give good results. It’s still not 100% perfect, but it will do because the result looks visually acceptable.
Next is to change the animation (sprite) corresponding to the direction of movement. So if the character is moving left, the sprite changes to side-view of the character and so on.
There seems to be a solutions IF the style of movement is Top Down Movement, cause I could look at examples provided and begin there.
But it seems I couldn’t find any examples which demonstrates change of animation in combination with Pathfinding. This is because I am not sure how to detect the direction of movement (or angle) in pathfinding route.
I tried Object.Angle() to figure out how to use it, so far no ideas.
Although, I was thinking of implementing a logic.
First I need to figure out a way to detect which direction the character is moving i.e. North, South, East, West.
For that I can put two objects say “NS” at the north-side of the scene (outside the scene boundary) and “EW” at the west-side of the scene (outside the scene boundary).
Now with a PATHFINDING behavior attached to the character,to detect if the character is moving north, I need to compare the distance between the character and “NS” object in the current frame with the distance that was in the previous frame. If this distance has decreased in the current frame, then the character is moving North and vice-versa for moving South. Similarly, it will be detected for West-East direction.
If this logic is okay, Can anyone help me with the expression for this? Do I need to get DeltaTime involved in the expression, as the checking of distance needs to done every frame?
Getting the expression right is tricky for me and I would really appreciate any help with this.
Seriously,looking at this example, there is absolutely no clue
how the animation of the Player tank is changing as per the direction?
Inside the sprite list of Player tank, all of the sprites relating to the tank are listed in Animation#0
where as Animation#1 there is a pea with a mysterious smile. Might as well throw in the Zodiac killer sketch in there, it will still have the same impact. Further, all the animations listed in Animation#0 are in separate rows as if they were separate animations, yet they all belong to Animation#0.
The only thing that’s new about the events is the use of Tank.Pathfinding::NodeCount() and Tank.Pathfinding::GetNodeX(Variable(i)) and Tank.Pathfinding::GetNodeY(Variable(i)) which at least I have no idea what their function is in this context. EDIT: Diving deeper, I understand that the green node markers are basically used to create a trail of the path. And these expressions are using a variable to create that path. (that still does not answer the animation mystery)
Double checking everything there is no hidden Function/Group/Java block that may be dealing with this behind the curtains. But there are no curtains here.
What is going on
My guess: May be this example was created in a very old version of Gdevelop. May be this example is still compatible with the new versions in terms of functionality, but with the issue of incorrectly populating the animation list as discussed above?
Only the author of this example could answer these questions? Is there a way to track down who that might be?
You are right, it was made in the previous GDevelop (v4). It’s still working but the features are not yet accessible in GD5.
Maybe you can copy-paste the object in your own project and replace the animations with yours, if you don’t want to go through the trouble of the direction algorithm.
Regarding that algorithm, you don’t need to add objects, you need to store the X and Y value, and then compare the stored X/Y to the new X/Y, and you can deduct direction from that.
You don’t really need TimeDelta, the events sheet is run every frame.
I would love to give Copy-Pasting a try but it seems copy-pasting objects across projects isn’t allowed.
I tried this in the web version of GD - doesn’t work.
I want to try on local machine but the second instance of GD get’s stuck at loading. Multiple instances of GD app isn’t allowed locally?
I tried copying object in first project, then closed it, opened my project, but pasting doesn’t work?
Can you confirm if this trick works?
Even if copy pasting works there seems to be a risk that if I advance way ahead in the project and then something related to pathfinding breaks, it may not be possible to solve the issue coz this Tank thing has ‘invisible’ stuff attached to it. There is a risk but I think I can take it as long as copy-pasting works.
You can paste across projects, but not across the web app.
You can open as many instances of GD as you want. I often have two or three opened. The only problem is that user settings don’t apply to subsequent instances (color theme, hints, etc), and the debugger doesn’t like it much.
Cheers
At first , to open a second instance of GD,I realized had to wait for at least 30 sec or more. (must be a problem with my machine or its a java update related thing that I have been avoiding for a month now)
It works as you have suggested above, without dark theme n all.
Copy-Paste worked, I fiddled with the settings of tank a little bit and voila!
IMPORTANT: While trying various settings in the pathfinding behavior attached to the TANK, I noticed that the ‘rotation’ needs to be ON for this to be able to work properly. The code (events) inside the TANK that is hidden from us must be directly related to the ‘rotation’ of pathinding behavior. The animation (or sprite in this special case) won’t change unless the rotation in pathfinding is switched ON.
I’ll keep posting on this thread, while I experiment more with this TANK. Such as renaming, changing it to custom sprite etc.