Saving Rogue Bike from a crash!!
Published 2 years ago
Programming of The Rogue Bike Begins
Holodeck Studios is about to release its first game ‘The Rogue Bike’, and I am one of the game developer of this project. In our previous blog, we discussed about the birth of the game idea and how Dash (our character) evolved from the concept. In this blog, we will be discussing on how we came up with game mechanics and physics of the game. This would include how we made physics of the Biker and obstacles, parallax scrolling, input system, etc. So, Hold your seats tight and get ready for the thrilling adventure of The Rogue Bike’s making.
Programming Begins
My first task as a lead developer for ‘The Rogue Bike’ was to build a tech demo for the team to explore. As a group we had to decide on a Game Engine to use. In the end we chose Unity, since it is the easiest for newcomers, and as a hobby developer I had used it in all my previous projects. Setting up the basics was fairly simple with all the assets one gets from Unity, such as the Character Controller.
Since Rogue Bike is all about bike action, the bike physics is immensely important. So naturally the first place to start was the physics for the bike. We found making a realistic bike system wasn’t as seamless experience as we hoped; but fortunately we found a remedy and moved on. If making the game was always as easy as free assets and code the role of the programmer would be quite different.
The Bike is a very important part of our game, so let's take an indepth look at how the physics of Bike was built.
While developing the prototype,we realized that, in a this kind of physics-based puzzle game, we would need more tools than we anticipated. As days passed everybody would suggest necessary improvements for the bike system. We would spend more time fixing bugs and do those necessary improvements. We went on with this, but it was taking lot of resources, and it was a development that we had to finish soon. You can probably imagine how this went, we remade the whole thing almost everyday, since the new features weren't compatible with the logic of the old ones. We were going to lose a lot of development time if this continued. We then finalized(fixed) the features for the bike and found out about some joints that unity already has that we can use to get the desired effect.
Unity 3D has a wonderful RigidBody and Joints system that can give you a lot of cool effects with very little effort. So naturally the first step was to build the Bike using these systems.We wanted real biking feel in our game like breaks, shock ups, etc. so, we used WheelJoint2D of unity for both wheels of the Bike. Suspension property of WheelJoint2D helped us  to get that shock up effects appropriately as desired. WheelJoint2D is stretched from the bike towards two wheels of the bike to get that suspension effect. Motor Property of this joint helped us to give speed to bike. Suspension property indeed have three sub-properties namely Damping Ratio, Frequency and Angle. Tuning these sub-properties, we got the desired suspension experience for the bike. When bike  impacts with an obstacle, or when it reaches it’s maximum distance, it tries to come back to it original position(pushed back). This is how the shock up will work for the bike.
Simultaneously with the physics of the bike we did animated Biker to get the appropriate feel. This animation is a simple sprite sheet animation, to get that windy effect for the biker. We used 4 frames in our spritesheets to get the desired effect for the biker. Used Unity 3d Animator Controller to control these animations. The combination of these two elements gave bike a very toony feel.
Rogue Biker in motion:
Rogue Bike one of the crash:
All these things effort combined makes the bike physics feedback pretty cool. There are of course more things that would have been great to add as well. At this time we were almost done with the important part of the game, but still there was lot to be done.
Now, next important thing was to make some obstacle for the game. We listed out all the obstacles that can be implemented in the game. We came up with around 10-12 obstacles. We splitted this work among two programmer working on the game for physics of these obstacles.
We came up with some of the following obstacles along with its details on how we built it:
Moving Ledges:
These are simple platform, which can be moved either ways (Horizontally/ vertically). We first made it a draggable object, so that it can be dragged by touching it. We achieved this by simpling using 2d colliders. Then we restricted its movement to one axis, depending upon its type (horizontal/vertical). Then we gave range for that movement, to limit its displacement distance.
Rotating Ledges:
These are simple platform, which is continuously rotating and stops when you tap on it. We achieved by connecting Hinge Joint 2D to a fixed point which acts as center for the joint and got rotation by motor connected to this joint.
Next thing was to detect touch and stop the rotation.We achieved this by simpling using 2D Colliders in Unity. As soon as collider detects a touch we stop the motor in order to stop rotation.
Hanging Weights:
These are Simple Weights hanging with a Chain/Rope, you can either cut the chain or rope to detach weight and make it fall or can swing the weight.
We built chain by series of Hinge Joint 2D connected to each chain part and to the last chain part  weight was connected using same joint. Used unity tutorial to get the desired effect.
Next thing was to detect touch on weight for swing.We achieved this by simpling using 2D Colliders in Unity. As soon as collider detects a touch we enabled dragging for weight. And for cutting the chain, we used another great feature of Unity i.e Raycast2D. We originated raycast from connect platform till the weight. If it detects touch, we cut the chain by disconnecting hinge joint from weight.
Oily Ledges:
These are similar to simple platform, which can be moved either ways horizontally But as soon as bike comes over this, it slips as there is oil spilled over it.
We first made it a draggable object, so that it can be dragged by touching it. We achieved this by simpling using 2d colliders. Then we restricted its movement to horizontal axis. Then we gave range for that movement, to limit its displacement distance. Next thing we wanted to give that slippery effect as soon as bike comes over it. We did achieved this by using Area Effector of Unity 3D. Area Effector tutorial ( from unity help us achieve that effect.
These are some of the Obstacles that we made for World 1 of the game. Use different combinations of these obstacles to make 20 different levels for the World 1. There are many more obstacles made for world 2 also using same techniques as discussed earlier. This is how we made different obstacles. If you have any queries can buzz me on
At this time we were ready with most of the levels for World 1, but still background was left. At the time we were working on the physics of obstacles and bike, our artist was making some background elements. Now we want to arrange those elements into a meaningful background for the game and also get that depth effect in background. We did achieved by opting parallax background scrolling technique.
Parallax Scrolling:
Scrolling Background can really help sell a 2D game and keep the performance high and the code efficient. There are many ways to move and scroll backgrounds, create the feeling of parallax.
Here are two solutions:
1. Make a perspective camera (just one) and put your layers at different z positions. Then all you have to do is make this camera move when your ortho camera moves. Because it's a perspective camera the parallax layers will move at different speeds depending on how far they are from the camera. You can use static batching with this method since the layers are not moving in the world, only the camera moves.
2. Move the layers from script. Each layer should move at a different speed when your ortho camera moves.
We used the first technique in our game. For more information on parallax scrolling using orthographic camera go to this link
Final Output of the Parallax:
Once we were done with background, most of our stuff was ready. We then just added stars to each level that we would give for completion of each level. And then UI/UX for the game was done by using Unity UI System and Particle systems. Followed by Post Production Programming for monetization (IAP and Ads).
Main Menu Page UI/UX:
Level Complete UI/UX & Particle System:
What's coming?
We're about to release in a couple of weeks, it'll be our first game which is a milestone for our team. Getting  something towards success always takes a bit of work, but it's already started paying off. So, your support is needed. Please share your view on this.
For more updates subscribe and follow us Facebook and Twitter.
Google Play Link For Game:
Check out Previous Blog.
I hope you have enjoyed the read.