I am making a fishing game where a fisherman swings a fishing rod up and down to (when pressing key D) throw a bait down into the sea, with a fishing line following the bait. While the fisherman is rewinding the line with the bait, the player should press left and right to try to catch as much fish as possible (yes the player will be able to catch more than one fish per throw ).
I have tried to drop the bait with a tween animation and made a line shape (shape painter) between the rod and the bait, but while playing the tween animation I don’t seem to be able to add a force (left and right) to the animated bait. What would be the correct approach here? Should I use the physics engine instead of a tween animation?
Understandably, because you are tweening bait to a position (X & Y), and so the bait object has a path to follow.
Why not just tween the Y position of the bait object, and modify the X position based on the left/right key presses?
Also, can I suggest some improvements to your events?
- Whether you draw from bait to rod or from rod to bait makes no difference. Have just 1 draw line action, at the very end of your event sheet. This way you won’t need any of the
clear the rendered image.
- Why are you hard coding the drawing points (the -320 and -420 on the position)? Make sure you uncheck this box on the shapepainter properties , and you can remove those position modifications. Otherwise GDevelop uses the relative position of the shapepainter to the origin, and adds it to any line drawn.
Thanks for your response @MrMen!
The reason I am aiming at both X and Y is that I want the bait to return to it’s original position (the rod). In the final version of the game the bait will go in different directions depending on when the player presses the key D, so the X value will increase or decrease while the bait is going down. Also the boat is rocking a bit, making the rod move slightly back and forth.
Thanks for your advice, that worked really great. I didn’t know earlier what unchecking that box meant.
Edit: I managed to control the return by adding a magnet extension to the bait and activating it while returning to the rod. By doing that I can use the left and right keys to push the bait sideways.
Instead of using tweens, could you reverse the magnetic extension?
Or could you look at using a force to push the bait down towards the target area, and use the left and right keys to apply a force in the respective direction? And stop applying the downward force when the bait is a target distance from the rod? This would be the standard force actions, not those for the Physics 2 behaviour.
Otherwise, if you use physics behaviour, you could use joints to limit the distance to let the bait out or pull it in. Or change the bait object’s gravity scale to get it dropping or rising.
Actually it works great now. In the next step I will use a tween in a 90° direction of the rod when releasing the bait. The rod will be rotating slightly back and forth around it’s handle. Thanks for your help @MrMen