Dev Blog

Monkey Mayhem – Dev Log 04

By October 9, 2018 No Comments

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:
		jumpForce = 0;
case ButtonState.Held:
	if(jumpForce < maxJumpForce)
		jumpForce += jumpIncremental;
		jumpForce = maxJumpForce;
cae ButtonState.Released:
	if (rigid.angularVelocity.z < 0)
		rigid.AddForce(currentForward * -jumpForce, ForceMode.Impulse);
		rigid.AddForce(currentForward * jumpForce, ForceMode.Impulse);

This ends up working quite well. The gif below doesn’t really show it well, but I intend to add some sprites to show you which direction you will jump in.

As you can probably see, I created some models in 3DS Max and put them into the game.

That’s all for this post

See you next time,


Leave a Reply