Posts Tagged ‘Unity’

With all the components ready from the tutorial I did I decided to build from that project and make it into Cancelled?. Using my sketches I created a block out of the level with some changes made through personal testing.

Sketch of sections one & two.

Scan0096Block out of section one.

Level 1 section 1

The only difference I made to section one was the inclusion of moving platforms in the cave instead of several jumps from side to side as well as an elevated plane for the extra life to stand on. I marked the spikes with a red texture to indicate them clearly.

This is the first secret area in the game which will be accessible by performing a wall jump with an extra life as a reward. I currently do not know how to code a wall jump in unity but I have an idea, if i remove the script which stops the character from sticking to the wall and use the slip material on all walls I want the character to slide down and left the walls you can wall jump on sticky you may be able to wall jump.

Level 1 wall jump

wall jump demenstration

I attempted the theory and took out the friction code and added the material. This part of the step worked perfectly making the walls with the material slippy and the ones without sticky but because of the direction the raycast shoots (down) you cannot jump while attached to the wall so I would need to know how to code a separate raycast or make it fire down, left and right. This is something I will look into later on if I have time. I feel if i add it to the existing code it would stop my jump because the raycast would then require a hit at left, right and down to enable the jump command.

wall jump attempt code

wall friction texture

I also tried to add a death tag which would kill the player when they touched an object that used it. This would be placed on spikes and down pit falls, things that should instantly kill a player. However the script would not work Unity did not complain about any errors and I copiedĀ  and modified the hurt tag script yet the player would not die on collision or lose any health. I left the failed script in there as well as the tag and just marked it out of use.

Failed Death tag script

Block out of section two.

Level 1 section 2

Level 1 bridge

Section two of the level however stayed mostly the same except with changes to the directions the platforms moved. I highlighted the area of the bridge I wanted to fall with a black texture to make it very clear as well as marked the enemy with a green colour. The enemy use to be able to run through all walls ignoring collision which was a real problem, luckily the solution was simple I just needed to add a ridged body component to the enemy like the player. Though I don’t have a combat script in place you can knock the enemy cube on its side and it’s movement speed is more than halved allowing the player to defend themselves in some way, a happy accident. I also did not add the destructible bolder or the one that chases you in section three because I was unsure of how to make the character damage the bolder, make them explode and in the case of the one that chases you make the platforms it touches fall these are all things that would require coding to perform and would take some looking into.

Sketch of section three.


Block out of section three.

Level 1 section 3

I only changed the spacing and direction of platform movement in this section as well as removed one of the speed up items as it was more of a hindrance then a help in my test runs. The speed up also increases the distance you can jump this will be made clear in the tutorial with floating text and is the reason why the first platform is so far away.

Level block out as a whole.

Level 1 full layout

I decided to add a wall at the beginning so you cant run off the stage straight away. overall I think the block out has gone well and everything is in place to have assets built and placed on top of them. Play testing the stage has pointed out a few flaws with the way the jump is set up as you can only jump if the center of your character is touching an object because of how the raycast works meaning if you fall on the spikes nine out of then times you can’t jump meaning you cant die because you cant collide with them a second time and you cant escape meaning your trapped. The script from the first tutorial seemed to have a jump set up that would fix this but the scripting for that was done in C sharp instead of Java so I’m unsure how compatible they both would be working together withing one model as the wall collision script it would need to get the information from would be withing the Java script. I also modified the reset script from the first tutorial so it moves the player to the correct spot to fix the endless drop when you fall down a hole. This will stay in place untill I can use a proper check point system.

reset script


Unity Tutorial 2.

Posted: January 5, 2014 in Aspects of Play
Tags: , , ,

I found another tutorial on YouTube that had more elements relevant to what I wanted to incorporate into my game like. speed boost, player controlled movement, moving platforms and enemies that follow you.

I started by creating the placeholders for the scripts, textures and tags as demonstrated in the tutorial. I then placed the blocks as shown and added the smooth follow script to the camera so it will follow the player ready for the second part of the tutorial.

Unity tutorial 2 screen 1

Unity tutorial 2 screen 2

In the second part of the tutorial I started by adding the ridged body component to the player using the add component tool within the players options this seems like a much more efficient way of doing it than I was shown in the last tutorial were it was added by navigating the components drop down menu. Next I went through setting up the speed parameters of the player and added a ridged body code to the player however it would just roll off the side so the next step was to freeze the z position, this limits the player to only being able to move along the x and y axis.

Unity tutorial screen 3

Unity tutorial screen 4

Next the tutorial talked me through the code to give you the control of the left and right movements of the player.

unity tutorial 2 screen 5

This line of code basically means 4 (which is the speed) times the key input, if it’s not pressed 4 x 0 = 0, if left is pressed 4 x -1 = -4 and if right is pressed 4 x 1 = 4.

Lastly for part two the tutorial takes you through setting up the jump commands and how to set up a raycast function. He explains a raycast function as a beam that shoots in a straight direction for as long as you set it to or until it hits something, it always shoots from the center of the object. The raycast that is shows shoots 0.01 below the character and if it is hitting you can jump if it is not you cannot jump.

unity tutorial 2 screen 6

Part three starts by showing me how to code the player so they don’t stick to the side of the walls this is a much more complicated fix than was shown in the previous tutorial were you created a slip material and added it to the object.

unity tutorial 2 screen 7

Next he went through how to set up the health of the player and how to link the damage to the hurt tag I set in in the first tutorial so all I need to do is add the tag to an object and it will damage my player.

unity tutorial 2 screen 8

Next the tutorial went through how to set up the speed up objects this was done in two scripts one section of the code was in the original script and the other would be added to the speed up object and call back to the other script.

unity tutorial 2 screen 9

unity tutorial 2 screen 10

The final part of the script added the time limit to the speed up and reset the counter is another is picked up.

unity tutorial 2 screen 11

unity tutorial 2 screen 12

The final part of the tutorial covered the moving objects script and how to set up an enumeration which lets me choose which direction the object moves with a drop box.

unity tutorial 2 screen 13

unity tutorial 2 screen 14

Lastly the tutorial goes through the chasing enemy script which makes the enemy’s chase you around.

unity tutorial 2 screen 15

This tutorial has given me all the basics I need to block out my level which I can then add to as I develop it.

Unity Tutorial 1.

Posted: January 3, 2014 in Aspects of Play
Tags: , ,

To got started with Unity I followed this tutorial I found on YouTube teaching you how to make a sidescrolling platform game.

I managed to follow the code easily enough but the tutorial was unfinished (only has two parts) and one piece of my code did not work correctly even though it was copied exactly. I am going to look for a more relevant tutorial to the play stile I am looking for as this tutorial has the character move automatically in sted of the player having direct control.

Unity tutorial 1 screen 4

Going through this tutorial helped me understand more of the functions of Unity and helped me get use to navigating in the program making me feel more confident to approach another tutorial.

Unity tutorial 1 screen 3

Unity tutorial 1 screen 2

Unity tutorial 1 screen 1

The last line of code in this screen did not work it was purpose to bring the players speed back to zero when they re-spawn but it does not and the player spawns traveling at the speed they were traveling when they died. I learned some useful things from this tutorial like how to take away the friction on the side of objects so that your character doesn’t stick to the side, though the value could be tweaked and maybe allow for a wall jump. I learned that you can set values in your code that can be edited in the objects properties instead of opening and closing your code all the time. I also found out about the key listings unity has and the ease of adding physics to a character, lastly that you can drag the camera name in the list onto the player and it will automatically follow them from now on.