Krilling Dev-Blog #11

Published April 16, 2024
Advertisement

Our steam page is finally up! If you are interested please go wishlist it here. Not much was done on my part this week so once again I will be talking about the side project of mine. For context feel free to read my previous posts about it. You can find my last one here.

So today I will be talking more about the grappling hook and several improvements I have made to it. To refresh memory the way I was doing the grappling hook was by converting the players velocity into the local space of the hook and then clamping off any velocity away from the hook. This works fairly well, but it isn’t perfect. One large issue was imprecision likely caused by floating point errors results in the player ever so slowly being able to shimmy down the hook as you can see here.

To solve this problem I added in an extra check for how far away the player is from the hook pivot position. If this distance is further than the desired hook length then I snap the player back in range of the hook. This adds just a little bit of protection from the player moving away.

Another issue was the swinging of the hook felt rather slow. I originally had solved this by lowering the amount of drag when the player is on the hook, but in playtests this revealed some issues. Players complained about it feeling like as soon as they jump off the hook it feels like they suddenly are in molasses. I decided that clearly the drag needed to be consistent to make things as smooth as possible. This meant I needed to increase the speed of the swing somehow. I started by increasing the gravity while the player is grappled. This was effective in increasing the speed but it also had the effect of making the swing rather low and short due to it being harder for the player to go up. It also added the problem of the hook swinging back and forth indefinitely when the player was pressing nothing.

At this point I transitioned to doing research, mostly on the physics of pendulums and about various programming implementations of them. Over time I landed on a formula for calculating the acceleration of a pendulum in the tangential direction. Here is a diagram for reference.

What I am looking for is a_t, the tangential acceleration, represented by s in the diagram which I have found a formula for in the force of multiplied by the sine of the angle to the pivot. In other words a_t = g * sin(theta). I then add this tangential acceleration to the original calculated relative velocity in the tangential direction. Then as normal this relative velocity is converted back to global velocity. The important part of this is that I am calculating the effect of gravity on the pendulum directly, meaning that while the player is grappled I need to turn off the normal affects of gravity. This gave great results giving smooth movement and a smooth transition to a full stop.

The last piece of functionality I wanted to improve was player input while grappled. Moving left and right while grappled felt a bit unresponsive and didn’t give the feeling of building up momentum to swing further. There was also the issue of the player being able to hold a direction and be stationary off to the side not directly below the hook which does not make very much sense.

To fix this I tried simply adding velocity in the tangential direction when grappled rather than just left and right. This gave a better response but still didn’t solve building momentum or the issue of being able to hold yourself off to the side.

I then transitioned to a new approach by completely disabling the normal movement input while grappling. Then I increase the amount the player is accelerating based on the pendulum calculation by multiplying it by some constant. The only caveat is we also need to figure out if the player input is in the same direction as the acceleration to make the player swap between left and right to feel like they are building up the swing. This all together resulted in a much smoother grapple mechanic.

That is the end of the improvements to the grapple mechanic. With The Krilling completed my posts for the next couple of weeks will likely either continue to be about this side project or about other experiments I am doing. I have plans to experiment a little with networking by implementing something simple in a LAN environment which will likely be the topic of the next post.

Previous Entry Krilling Dev-Log #10
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement