Hello.
I am having trouble picking the object when the player is really close to the tree none of the wood spawn and only one adds to the total count…
None of the wood is spawning because you’re trying to spawn wood at the coordinates of an object that no longer exists. You need to delete Bigboi after you have spawned the wood. You also need to spread out the spawn location of the wood otherwise they will all be spawned in the exact same place. You could add a random() value to the spawn coordinates to help mitigate this. Like create wood at Bigboi.X() + Random(50), and do the same for the Y coordinate. This will also fix the issue of only one being added to the variable.
BTW instead of copy and pasting a bunch of the same events, you can use a repeat event.
As stated, the wood is all being created at the same position so it’s detecting the collision with all of them just once which in turn triggers the actions just once.
There are multiple fixes. You could create just 1 wood object and then add a fixed quantity for each one or add a random number.
Instead of adding 1, you could add the number of instances that are picked by the collision using the PickedInstancesCount(wood) as the quantity.
You could add a for each object subevent and count the objects separately. Probably not needed in this situation but helpful if there could be different types of objects in collision at the same time.
So i did as you said and what is happening now is the wood is getting spawned at the bottom right of the screen and even still whenever the PLAYER is near the spawn point of the wood it just doesn’t spawns the wood and doesn’t adds the count as well.
I did what you said and the object picking is working fine!! Thank you.
The code looks good but the structure is a little off. The repeat event needs to be a subevent of the line before it otherwise it runs regardless of the random number.
The delete line needs to be a spot to the left so it’s equal with the repeat otherwise it will repeat 13 times and the Bigboi won’t exist to be used as reference so it uses 0 for both the x and the y. If it’s even (not a subevent) it will execute after the repeat.
The final collision event group will only trigger if all of the events that it’s a subevent are triggered to trigger. So to work all of the time, it shouldn’t be a subevent. It needs to be all the way to the left. No indentation.
It looks good. Does it work?
Yes it’s working fine just a little confused with position of drops like it always comes from the right corner. Any idea how to fix that?
What do you mean by “drops”? The logs? If so, the logs will be created at the x(),y() position of Bigboi. By default, the x,y is the top left corner unless you change the points. Where do you want the logs to spawn?
You can change the origin point or more preferably add a custom point to the sprite and use it with the random number to add some spacing.
https://wiki.gdevelop.io/gdevelop5/objects/sprite/edit-points/#add-custom-points-to-a-sprite
I meant the logs, I do have specific points for the drop but the problem as far as i can understand is that whenever THE PLAYER is cutting the tree and standing close to the log creation point and as soon as the logs are getting created it touches the player’s collision box and the logs get deleted.
And it happens so fast, so it’s impossible to see.
So what i am going to do is add some more animation to the tree and then choose a new spawn point in those animation which is going to be always far from the player.
So thank you very much for helping me!