# Monkey Mayhem – Dev Log 04

October 9, 2018 Dev Blog

Welcome back to another development log. Its been just over a week since I last posted, so I’m going to catch you up on a couple of things.

We as a team sat down and tested out the game for a bit. We decided that the controls still don’t feel great, so I went back and changed them again.

We also decided that we wanted the detaching from the branch to be more like a jump that can be adjusted. So I’m going to show you some of the code for that too.

Just to remind you what the game was looking like, I’ve added the last gif below.

## Even more forces!

Let’s start with the players rotation. Before we were using the AddTorque function from the rigidbody. But while I was playing around with some code, I determined there was a more reactive way of doing it. The new code can be seen below:

``rigid.angularVelocity += new Vector3(0, 0, (Input.GetAxis("Horizontal"+ playerSuffix) * force));``

You may notice that we are now incrementing the velocity value based on the players input. By having force as a public variable, I can fine tune it at a later date.

Next lets go into the detaching from the branch.

Before, we were just detaching from the branch and adding the current forward but this didnt feel right. I found that the jump didn’t react properly if you were going clockwise around the branch. The way I solved this was by getting the current angular velocity of our Z axis and used an if statement to check if it was positive or negative. I then multiplied the jumpForce value, dependent on the if statements result.

To increment the jump force, what I needed to do was store the current state of the input and then adjust the values depending on that state.

I used a simple switch case statement to do it for me. I didn’t want to use the Input.GetButton functions so that I can implement a different input system at a later date.

``````case ButtonState.Down:
if(attached)
{
jumpForce = 0;
}
break;
case ButtonState.Held:
if(attached)
{
if(jumpForce < maxJumpForce)
jumpForce += jumpIncremental;
else
jumpForce = maxJumpForce;
}
break;
cae ButtonState.Released:
Destroy(hinge);

if (rigid.angularVelocity.z < 0)