Ask here your questions to get help using GDevelop.
By SYNYST3R1
#70648 What is the default directory when you write to a file? I saved my inventory and I want to delete it.

Is there any way to fix pathfinding making the player jump all the way back to where it first started? It seems to do it when I get close to an obstacle.

Using the inventory example how would you go about doing max stacks and having the next stack go to the next slot and start at 0? I have a variable for max stack and it goes to the next slot, but it starts at the same number as previous slot since inventory::count counts everything in the inventory.

What is the best way for doing animations based on direction when using pathfinding? Right now I'm using what's in the screenshot, but the animation doesn't update when the player goes another direction because my prevX/Y variables don't update when he changes direction. Is there a better way to get the player direction?
Image
By MattLB
#70746 I've never used inventory or pathfinding, but according to the wiki, pathfinding uses nodes and "Expressions are available to get the X/Y position of the previous node or next node, so you can, for example, turn the object according to its movement."
User avatar
By ddabrahim
#70747
What is the default directory when you write to a file?

If using the storage actions it is web storage. I don't know about the new file system extension.

I want to delete it.

Just clear your browser cache or open up the developer console and you can find the data in the storage tab.
Or in case you want to do it in-game just write over the data with default values or empty values.
pathfinding making the player jump all the way back to where it first started..when I get close to an obstacle.

I have never experienced this. If you move something from A to B using pathfinding the object should avoid all obstacles and stop at point B and should not jump back to point A :?
Pathfinding got an event to check if object reached the destination maybe you want to use that to stop whatever is that you are doing when the object reached point B and probably you don't want to check collision with obstacle while the object travel with pathfinding. Let the pathfinding do it job which is avoid obstacles.

Using the inventory example how would you go about doing max stacks and having the next stack go to the next slot and start at 0?

The trouble is the Inventory extension count items overall in the entire inventory and in the example we are using the expression to get number of items in the entire inventory to display in the slot.
The solution is to have an object variable for each inventory slot to count the number of items in the slot and then when you add an item to an inventory, check this value first. If the value is equal to the max number, look for a new empty slot and for the text to display the number of items in the slot use the object variable of the slot instead of the inventory expression. But then you don't really need the Inventory extension any more to store items. You can just create your own Inventory system from scratch using object and structure variables.

What is the best way for doing animations based on direction when using pathfinding?

By checking the direction of the player? The pathfinding extension can rotate the object for you as moving on the path and there is an event and expression to get current direction of the object. So, all you need to do is take the direction in to account when you change the animation. If you don't want the player to actually rotate, what you can do is to have an invisible object that is rotating on the path and make the player object follow this invisible object. So you are essentially controlling the invisible object and the player object only follow the invisible. And then you can take in to account the direction of the invisible to change animation of the player accordingly.
By SYNYST3R1
#70766 Thank you for the help that fixed everything. I have another question, when using pathfinding for AI how would you go about stopping the AI from being inside each other and walking in straight line?
User avatar
By ddabrahim
#70768
A lot of times they will just clip through corners of an obstacle as well

You can set the border size in the properties of the pathfinding behavior, it is basically the gap between the path and the obstacle. If the object moving on the path is overlap the obstacle, set the border size higher. You can also change the cell width and height of pathfinding, the smaller the value is the more accurate the path going to be but it is also require more resources.

how would you go about stopping the AI from being inside each other

This is a tricky one because GDevelop can not work with instances of the same object. You can't just simply check collision and distance between instances of the same object because GD doesn't know which instance you want to compare to which and on which instance you want the action to be executed.
I don't have a nice solution for this one.

One thing you can do is when you move the AI on a path apply some random value to the position of the target so one AI let say stop at 100;100 the other stop at 120;132 the next one at 130;140. You can also take in to account the size of the AI to make them stop next to each other. But they are still going to move over each other when they are moving.

An other thing you can do is a bit overcomplicated and probably you are not going to like it but the idea is to have an invisible object that is the same size as the AI object. Create this invisible object on top of each AI and link this invisible object to the AI they are colliding with initially (at the beginning). Then, check collision between the AI and this invisible object and check if they are linked. If they are not, that means the AI is colliding with an other AI and stop the AI colliding with the invisible object with no link to it. But then one AI may doesn't move and you still need to move the other AI around to get to it destination so the next thing you can try is to create an obstacle temporarily in position of the AI that is not moving and find a new path for the one moving with the new obstacle in the picture and then delete the obstacle. Ugly solution but could work :lol:
By SYNYST3R1
#70769
ddabrahim wrote:
An other thing you can do is a bit overcomplicated and probably you are not going to like it but the idea is to have an invisible object that is the same size as the AI object. Create this invisible object on top of each AI and link this invisible object to the AI they are colliding with initially (at the beginning). Then, check collision between the AI and this invisible object and check if they are linked. If they are not, that means the AI is colliding with an other AI and stop the AI colliding with the invisible object with no link to it. But then one AI may doesn't move and you still need to move the other AI around to get to it destination so the next thing you can try is to create an obstacle temporarily in position of the AI that is not moving and find a new path for the one moving with the new obstacle in the picture and then delete the obstacle. Ugly solution but could work :lol:


How do I go about having the "hitbox" follow the enemy instance it is linked to? Nvm I got it, thank you. For anyone searching in the future, I just needed a for each object loop and take into account all linked then do hitbox position to enemy position. Well it works, but man is it laggy with more than a few enemies :lol: