I'm trying to make a 2D runner / gymnastics game, where the player needs to use the arms (UP arrow) or the legs (DOWN arrow) to go through different equipment and score points. But I'm having trouble making the player grab the horizontal bar, rotate around it with the right angle and speed and then jump with the momentum acquired in the bar. After trying for a few days with no success, I'd like to ask for someone to help me.
[If it's not recommended to put so many images, I can remove some of them. Also, I can provide the project file if needed.]
I want the player to grab onto the yellow stick when he is in contact with the yellow circle and pressing UP. Then, while holding the button, he keeps rotating around it and gaining/losing speed. When the player releases the UP arrow, I want him to jump in the direction he was facing with a right speed. I already tried understanding the "How do I?" tutorials, but I couldn't make them work how I wanted.
Here's how it is right now:
At the moment, the player just attaches to the yellow circle's image point with the Pin behavior and just falls flat when the player releases the button.
Here's the code for the horizontal movement:
How I make the player attach to the yellow circle:
First, I check for the UP arrow, then check if he's not on the floor (I changed in the code already, the image is not updated). If he's not already in the bar, the turn speed is set based on how fast he was going. After that, I check the angle between the circle and the player and position the player on the circle's image point, to pin on it. The angle_bar_to_player checks are there just to set the rotation direction of the circle. I feel there's something off with that - like if the player doesn't grab at the right angle.
The code that runs while he is holding onto the bar:
It just updates the the angle between the circle and the player, then it rotates and adapts the player's sprite.
What happens when the player releases the UP arrow:
It just Unpin's the player. I want him to jump in the direction he was going while on the bar.
Can someone help me with this, please?