
Semester 1 Blog
Each entry below represents a weekly task conducted for my Games Creation module, it is organized to be latest first and shows the progression of the Ragdoll Panic game.
12/12/2016 – 18/12/2016 (Ragdoll Panic)
In the final week, many “game juice” mechanics were implemented to make the game more interesting. Power ups such as the hearts and clocks were animated to make them more eye catching. The heart animation increases and reduces in scale which makes it difficult or easier for the player to reach the power up. This makes the heart power appear to have a heartbeat which increasing and decreasing, something which the user can easily recognise as a positive feature. The large and small clock hands were animated to rotate in a circular motion rapidly to simulate a panicking clock, implementing this made the clock appear more dynamic and interesting. The Rotate() function was used in the CoinSpin script which makes the coins rotate around the y axis replicating a rotating coin, this feature was implemented as it’s common in 2D games.

In the final week, the Christmas skin of the ragdoll was also implemented in the game, it has the same mechanics as the player, however it’s more ascetically pleasing and is ideal with timing of the game launch. Including a Christmas version of the ragdoll during the Christmas period increases customer curiosity and could possible attract potential audiences. As it provides a new dimension to the game. This was simply implemented by changing the sprite in the Sprite Renderer component for each part of the body to the new Christmas version of the sprites, which together made a Christmas ragdoll appear.


Coin spinning animation
Clock handles spinning animation
Heart shrinking animation


Eyeballs look downwards when user has not clicked on a lamps the ragdoll is going burn in the fire.
Eyeballs look at where the user clicked on screen.
Completed eye movement for ragdoll. The ragdoll looks where the user clicked. This is executed using the eyeMovement scriot which calculates the distance between the eye positon and position clicked by the user and limits the eyeball to look in that direction.

Another feature which was included was the vibration mode, the device vibrates as the ragdoll dies. This simple was added to the gameOver script using the Handheld.Vibrate() function it’s essential as this functionality is only available on devices and vibrating the device clearly alerts the user notifying them and providing the feedback that the ragdoll has died.
05/12/2016 – 11/12/2016 (Ragdoll Panic)
​




In week eleven tilting was added correctly as code CreateHook script, the input from the mobile device was received as Input.acceleration.x. This was multiplied by large values to and implemented using the AddForce() function. The user is only able to tilt the ragdoll when the rope is created, this way the rope and ragdoll can be tilted left or right by the user to avoid enemies or collide with power up and collect them.
Added brown rope material
Ragdoll can go through lamp
Lamp can swing using Hinge Joints
Eyeball looks around

21/11/2016 – 27/11/2016 (Ragdol Panic)
Following the milestone sheet my responsibly was to start implementing eye movement of the ragdoll in week nine. However, as the game would be tested by lectures the following week (provisional marks are given) I decided to switch my task and implement titling as this feature is more essential to a mobile game. After creating and implementing an accelerometer script which did not work correctly I decided to scrap as it had to be continually tested on an android device which was difficult to access outside a class environment.

07/11/2016 – 13/11/2016 (Ragdol Panic)
Overcoming the add force issue was the most challenging aspect of coding as the problem was incorrectly identified to be a collision problem between the lamp and ragdoll. This led to checking the collision matrix in week seven, making and assigning layers to the ragdoll, rope and lamp objects. The matrix is used to detect collisions and a possible solution was to disable the collision between the ragdoll and lamps. Therefore, the lamp was assigned the layer “NoCol” (referencing objects which have collisions turned off) and the ragdoll assigned the layer “Player” and the collision checkbox between them was unchecked.
This attempt did not work as the player would continue to hang from the lamp very closely. The issue was due to the code in which the distance of the rope was set, it caused the ragdoll to pull itself towards the lamp if the distance between the ragdoll and lamp was greater than 0.05 and keep the ragdoll there. This worked corretly pulling in the ragdoll however, this didn’t allow the ragdoll to fly upwards and consequently it was modified to the following code.
​
​
​
​
​
​
​
​
​
This snippet of code firstly checks if the distance between the ragdoll and the lamp is greater than 0.05 (line 36) and then after updating the rope’s position it reduces the length of the rope pulling the ragdoll towards the (line 40) by a small amount until it reaches the distance 0.05. Once this distance is reduced to be less than 0.05 then the else if statement is entered (line 42) in which force is added upwards (line 46).

24/10/2016 – 30/10/2016 (Ragdoll Panic)
During week five the next phase of implementation was carried out in which the lamp sprites added and attempts were made to add force to the ragdoll so it fly’s upwards when it’s very close to the lamp, however the ragdoll would just hand off the lamp. At the time this was thought to be an issue with the Box Collider 2D component of the lamp’s as they had recently been added which lead to attempting to fix this issue by focusing on the Box Collider 2D component of the lamps.

05/12/2016 – 11/12/2016 (Ragdoll Panic)
​




In week eleven tilting was added correctly to code the CreateHook script, the input from the mobile device was received as Input.acceleration.x. This was multiplied by large values to and implemented using the AddForce() function. The user is only able to tilt the ragdoll when the rope is created, this way the rope and ragdoll can be tilted left or right by the user to avoid enemies or collide with power up and collect them.
Added brown rope material
Ragdoll can go through lamp
Lamp can swing using Hinge Joints
Eyeball looks around

28/11/2016 – 04/12/2016 (Ragdoll Panic)
​
Thoughout week ten many minor changes were made to the game as bugs were identified as feedback was provided on the game. The issues associated with ragdoll are listed below.
​
1. Ragdoll required a more fluid connection when flying upwards from a lamp. This was fixed by adjusting the code which adds force to the ragdoll, instead of adding 1000 units of force 2000 units were applied to make the ragdoll fly higher.
​
​
2. Ragdoll’s torso component repositioned incorrectly. This was fixed by removing the Rigidbody2D component on the parent gameObject ragdoll, which caused the torso to fall.
​
Torso gameObject with parent Rigidbody2D Torso gameObject with parent Rigidbody2D
​​
3. Major bug which affected gameplay was the rope appeared to hook onto centre of screen. This was fixed by changing code if statement in FixedUpdate() function which checks if user has clicked on the screen. Now the user can click on lamps and the rope will only appear on lamps and not to the centre of the screen.
4. Sometimes user clicks and holds to create the rope this makes a rope which doesn’t pull the ragdoll towards the lamps, leaving the player to just hang and swing. Fixed by changing code so the rope is now created if user clicks on lamp once or if user clicks and holds onto the lamp.




Issues 3 and 4 were overcome using the if statement above it allows the user to create rope clicking once or holding downs on the screen. A new script CreateHook was developed using the previously implemented grapplinghook script. CreateHook includes a simple coroutine called makeRope() instead of checking in the update which is how code was previously implemented since week four as this is the correct methodology. Also code has been modified from being called in the Update() function to the FixedUpdate() function as Update() function can take longer to process one call to the next increasing the time between calls. This was changed to FixedUpdate() as this has the time between calls and as this is more appropriate to dealing with Rigidbody physics which is heavily relied on.
​
All these issues were identified as only we tested the game, it was easier and unlikely to for our group to identify these bugs are we knew exactly how to play the game correctly and therefore assumed they were not problems.
During this week, the lamp objects were also updated to include hinges using Hinge Joint 2D component so they swing instead of appearing static. This enabled a rope attached to a lamp to swings dynamically.
​
Adding hinge joints to lamps led to a problem where the rope end-point which attaches to the lamp didn’t update when the lamp swings, it appears as if the rope is just attached to nothing. To fix this issue the lineRenderer code which implements rope was adjusting. The lineRenderer’s vertex 1 (end-point of the rope which attaches to lamps) was changed to a local position.
The code above demonstrates the change as the vertex 1 now is set to be a TransformPoint in world which updates on the position of the distanceJoint.conncetedAnchor which is the lamp at the end-point of the rope.
​
As these core mechanics were fine-tuned “game juice” was focused on and movement was added to the ragdoll’s eyeball to make the eyeball look in the direction the user has clicked.
14/11/2016 – 20/11/2016 (Ragdol Panic)

As this issue was fixed it allowed the ragdoll to connect to a hook and jump up, at this stage the ragdoll could perform core game mechanics and in week eight the ragdoll skin was implemented. This simple process was overcomplicated due to the scaling and length to width ratio of the new ragdoll skin. The initial ragdoll was created in Unity using the default Unity scale and the ragdoll provided by artist was at created in Photoshop with a extremely larger scale. The correct scale was implemented through iterations of trial and error, by reducing the length to width ratio of the new ragdoll in Photoshop then implementing and testing it in the Unity Editor to see if it’s the same scale as the previously used ragdoll. Testing the first iteration of the new ragdoll skin demonstrated progress as instead of using a rectangular shaped ragdoll there was a character which cook hook onto lamps and then fly upwards off lamps, which marked a key point as started to appear as a game.
17/10/2016 – 23/10/2016 (Ragdoll Panic)
To overcome this major issue in week four a completely new scene and rope mechanics were created. Major changes are listed below:
-
Changed camera angle to orthographic view for 2D view.
-
Using Distance Joint 2D component to represent rope which hooks onto objects.
-
Adjusted hierarchy of Ragdoll gameObject,
-
Ragdoll’s hand also has a Hinge Joint 2D which connects the hand to relative to the position of the Arm’s Rigidbody 2D.




This rope simulation doesn’t use green circles (nodes) like previously, instead this has been developed and modified to hang onto non-kinematic objects, the 2D white cube which can fall downwards.
Hierarchy is changed so RopeshootLeft object is child of Left_Arm.
The blue circles represent the anchor and connected anchor point. This represents the left hand and therefore has Hinge Joint 2D component so this hand can rotate around the left arm.

This component is attached to the RopeshootLeft gameObject, it’s a crucial component which simulates the rope mechanics. The DistanceJoint2D is essentially the rope, as it simulates the physics of the rope swinging. The Ragdoll’s hand (RopeshootLeft) uses Distance Joint 2D and lineRenderer to create a red rope which hooks onto objects which can fall downwards. Using this component, the rope mechanics evolved and the player can create a rope which works with objects which are falling downwards.
Grapplinghook script
The code above is still used in the game to create the rope. It checks to see if a click has occurred on the screen using the “Fire1” button (line 54) and creates a Raycast from the ropeShootLeft gameObject to the position clicked on the screen (line 58). This Raycast is stored in a variable named hit to identify if the position the user clicked has hit an object tagged “Square” (line 60). The square at the time was a reference to object which represents the lamps as the rope would hook onto lamps. Once the user has clicked on an object which is tagged “Square” it enables the distanceJoint (which simulates the rope in physics) and a calculation is s made to identify the edge of the object which the joint can be attached onto, this is stored in the variable connectedPoint (lines 63-66).
​
The distanceJoint.distance uses the gameObject’s position and the hit.point’s position (the clicked object’s position) and returns the distance between the two vectors in the form of a float, which is the distance separating the two ends of the joint. This joint is displayed as a rope using a lineRenderer line, this line is what represents the physics of the rope.



This blue circles represents the connected anchor point from which the ragdoll can swing from. The green line represents the distance joint.
This blue circles represents the anchor point. This is the 2D Distance Joint component which swings the ragdoll.
The green line has been converted into a red rope, this red rope is the lineRenderer, which is positioned to start at the anchor point end at the connected anchor point. The 2D Distance Joint still exists however this red rope is used to display it every frame.
Visual explanation of rope
​As this stage a working prototype of the ragdoll had been developed as it could perform ragdoll like behaviour and a rope could be created which was suitable for the demo test.
10/10/2016 – 16/10/2016 (Ragdoll Panic)
Initial Rope Mechanics
Rope mechanics were implemented during week three, a dynamic rope is instantiated and displayed using the lineRenderer when clicked on certain gameObjects. The rope swinging functionality was created using nodes which allows the rope to bend and swerve dynamically, this is represented in the green circles. Each green circle is a point which makes the rope swing onto the next one. Using an online tutorial code was implemented for this.
It provided very effective physics simulation of a rope, however the rope could only be connected to static objects which are not affected by gravity. The game concept at the time inlcuded dynamic lamps which fall down and therefore this couldn’t be used as this rope mechanism required a static object. Testing with a non-kinematic object which falls down resulted the green nodes being unable to update positions and instead of providing rope like behaviour it displayed an endless rope which continoued to extend.

03/10/2016 – 09/10/2016 (Ragdoll Panic)
Creating Ragdoll Behaviour
Developing the main “ragdoll” character was my task. Creating the ragdoll became my responsibility as I initially created the first iteration of the ragdoll using simple 2D sprites to represent body parts. This premature version of the protagonist simulated ragdoll like behaviour using the Rigidbody2D and DistanceJoint2D components. Hinge Joints allowed the ragdoll’s arms to rotate around anchors points simulating hanging behaviour.


Blue circle in the centre is represents the anchor and connected Anchor points which the arm rotates around.
​
The half green circle is the area in which the arm can rotate, this is limited and adjusted for each arm, leg gameObject in the Use Limits section.
The connected rigidbody is set to the torso gameObject as this is how an arm joint is connected to the body.
03/10/2016 – 09/10/2016 (Ragdoll Panic)
New Android Game Idea
​
A 2D android game in which a ragdoll moves up the screen by hooking onto lamps. The aim is to post a high score, this is an endless runner game which a ragdoll climbs upwards.
​
Development software: Unity3D,
Programming Language: C#
Platform: Android Mobile
Role: Junior Programmer

