Hi guys! I have a problem. I’m trying to make a fishing top down. I have a ship that has a radius. If a fish falls within the radius, a progress bar appears and when it is filled to 100% the fish disappears. But when two fish fall into the radius and the second fish becomes closer to the ship than the first, the ship captures the second fish and progress begins again. How can I make sure that the ship does not switch to the second fish until the progress is 100 percent full? The fish are multiplied objects and I need to make sure that only one fish is selected.
You could use a link between the boat and the fish:
https://wiki.gdevelop.io/gdevelop5/all-features/linked-objects/
Unfortunately, I was unable to achieve the desired effect with the help of your advice. Perhaps I’m doing something wrong and the ship is still switching to the second fish. How can I get the ship to remember only the first fish? Perhaps there is some tutorial? Or maybe there is another solution to my problem? If you could show me how to do this, I would be very grateful to you.
This is what it looks like now.
Have you tried using a boolean object variable for the fish?
When you hook one, you toggle the variable to true, except the hooked one and toggle it again when bar is 100%, and use in the condition to get it only if variable is false.
You could assign a number to a variable to each one as they are created. There are many ways to do this. You basically just need to find a way to differentiate between multiple instances and filter the rest out. To stop from switching to the others before one is finished, you could toggle a boolean variable when one begins, and have the boolean variable = false as a condition for hooking a new one.
Here’s an example using 2 variables. A scene boolean that works like a mode indicator to tell if there’s a fish on the hook and an object variable to mark the fish that’s on a hook. If the fish is caught then you delete the fish and set the scene variable back to false. If the fish can get away the you would set them both to false.
For this example, I have 3 objects. 2 sprites (fish and boat) and a shapepainter to draw the line.
You might need other booleans like isFishing or boatIsMoving
Edit: I should’ve mentioned for testing, the fish and boat have the dragable behavior.
Yes, I use variables for this, but the problem is that when other fish fall into the radius, they also become true and the choice jumps to other fish. I can’t get the logic right so that other fish don’t become the truth. I was able to get only one fish to be selected, but when it leaves the radius and other fish remain in it, they are not captured. To repeat the capture, I have to swim away from the fish so that not a single fish remains in the radius.
Guys! I am very grateful to you for trying to help me.
Here’s a slightly different version which uses your red zone.
2 sprites (fish and ship) 2 shapepainters
Try it. The fish and ship are dragable for demonstration.
Thank you! I’ll try to do it as you showed and tell you about my results.
Everything worked out! Thank you very much for your help! I couldn’t cope with this task for two weeks, but now I’m happy! Thanks a lot!