Friday, 8 January 2016

To double jump or not to double jump that is the question

Back again with an update on how the game is going. So today I implemented three new things to my game. These being a double jump, wall jumping and win condition. Let's start with the win condition as that's the easiest to explain. The goal of each level will be enter the portal to the next level these being just a blue square as a place holder for the time being. Since we only have one level at the moment when the player collides with the square it calls the Application.LoadLevel to load the first one again. This is done in the OnTriggerEnter2D function in the goal script.
So lets talk about the double jump for a minute. Originally the game didn't have a double jump and functioned fine without since the level itself is pretty small. So was it really necessary to implement? Since I was unsure it was best to implement it and see what it was like. I implemented by adding a bool variable called doubleJump and checked if we are not grounded and doubleJump is false we can jump again and after we do set double jump to true so we can't keep jumping forever. So it worked fine you can jump and double jump, the problem I have it is a bit too easy now since the player jumps too high. I tried lowering the jump height but then the player doesn't jump high enough. I could be wrong though since the game is bare bones at the moment and there are no obstacles in place currently. In the future it might be important but for now I need to tweak the jump height and see what works best. If I don't like it I will go back with the single jump. Sometimes simple is best.

Lastly let's talk about how I attempted to implement wall jumping. So for starters I didn't really get this working properly the way I wanted. It only worked to an extent. I did this by casting a linecast from the player and if the linecast hit an object tagged wall the player was able to wall jump. The wall jump code looked like this:
 myBody.AddForce(new Vector2(jumpForce, jumpVel));
That was all needed to bounce off the wall but the problem was that it only jumped you one way. To fix this I added an enum called direction. This would check the players current direction than bounce the player in the corresponding X direction. Again the player could jump off wall to wall the problem was that you had to move the player toward the wall or nothing would happen. In end I ran out of time so I left it out for the time being I will do some research on a better solution in the future.

No comments:

Post a Comment