Monday, 20 July 2015

Score Attack Astronaut Devblog

Over the past couple of days I've been working on my astronaut game and so far everything's going a lot smoother than I ever expected it to! So far I've managed to get the players movement and shooting mechanics all set up and have a working random spawn system for the falling debris and the enemies. 



As  you can see in the preview above there are a couple of placeholder graphics mostly in the form of the giant cubes that fall from above, these cubes will be replaced in the future with things like meteorites and shooting stars, you may also have noticed that the player only faces in one direction regardless of the direction they're moving in. Changing the direction that the player faces is one of the next main things I want to get around to fixing as well as animations for each of the enemies. 

So far I only have 1 enemy type in the game in the form of a simple orange blob (Shown below) but by the time the game is finished I aim to have at least 3 enemies built in. The enemy below may seem a little simple, this is because i want my game to appeal to everyone so I chose to go with a simple cartoon style alien because its the sort of thing that most people will be familiar with. 



Having multiple different enemies in my game will add some variety so the player isn't seeing the same thing over and over again. As well as just having extra enemies in my game I intend to make it so that they take between 1-3 shots to kill to add a little bit of extra variety to the game. 




With the basics of the main mechanics set up I also created a script to control other properties of the game, this script destroys any aliens or bullets that go off of the edge of the screen which stops the game from lagging out or slowing down. This script also controls the games timer which works as a visual indicator to show the player how much game time they have left. The only other mechanic I really need to set up is some way to add a value to the score each time an enemy is destroyed and then the game will be in a playable (yet super rough) state. 

If everything continues to progress as well as it has been a rough playable version of the game should be ready in the next couple of months on itch.io . After that I plan to keep working on the game to polish it and iron out any bugs then work on getting the game working on a mobile device. I'll try to keep updating this regularly for anyone who's actually interested :P but  other wise keep an eye on my Twitter (@markimo2) for other updates.


Thursday, 4 June 2015

Digital Futures Showcase WIP

Just wanted to use this to show off a little WIP animation that i'm busy creating for a showcase that i'm going to be part of in the next couple of weeks.


Overall this animation isn't going to be anything special as its just a little idea that I came up with while go and wanted to finish up specifically for the showcase. 

Thursday, 23 April 2015

Unity Scripting And Sharing

So being a big fan of scripting for games and making all of the mechanics and controls work to help the game come to life I've come up with the idea of sharing what knowledge I have by creating a library of scripts alongside my tutorials. From now on I intend to use whatever file sharing service I can to share some of my best and most useful scripts. All of these scripts will be written and used in the Unity game engine.

I'll post each of the links below along with the name of the script and a short description which explains what the script does. 

If any of these links don't work please either tweet me or comment letting me know asap :) 

- Enemy/Player Located Script:

This script can be used for NPCs, security cameras and anything that is used to detect something or someone. Setting up the script is simple you just place the script on the thing which will be doing the detecting and tag the object or player with a "Player" tag (this can be changed in the script itself).

https://dl.dropboxusercontent.com/u/59486345/PlayerSpotted.cs.zip

- Player Dies If They Stay In The Area Too Long

This one checks to see if the player has a tag of "Player" when they are within the trigger area and then kills/destroys them if they stay in the area for more than 5 seconds (this can be changed by changing the number in the brackets).

- Score System

I figured this would be one that people would be in need of a lot. This script adds a certain amount of "score" to the counter each time the player enters an object which has the tag "PickUp" on it (this tag can be changed in the script). You will also need to create a "Text" object using Unity's new UI system so that the script has somewhere to print the score. 

https://drive.google.com/open?id=0ByTYhg5RcS2pS3pWY1dDa3lPYUE




Wednesday, 11 March 2015

Weapon Animation Experimenting

Being a big fan of both animation and video games I decided to mix the two together and start experimenting with some first person weapon animations. Below are two hammer attacks that I animated using Blender. So far you can see there are no arms or hands connected to the hammer but that'll definitely be the next step as well as adding a texture to the hammer. 

The first one is just a simple right to left swing with the idea of it being used as a basic attack. The second one shown below is a top to bottom swing for a more heavy attack swing. 







Friday, 30 January 2015

Blender Tutorial: Switching Cameras To Create Different Camera Angles In Animations

Different camera angles always make animations more interesting and usually look pretty cool at the same time. Making cameras switch in Blender is actually reasonably simple all you need to do is set up a marker and then bind the camera to that marker. 

Start off by adding your extra cameras to the screen, you can do this by pressing Shift + A and select camera from the list much like you would when you're adding other mesh objects to the screen. Once these cameras are set up position them around the scene so that they will capture each of the camera angles that you want. For the sake of testing to see if everything is working it may be a good idea to place the monkey head in the scene so that it can be seen by each camera. This way when you test your animation as each camera switches you will see a different section of the monkey.

Once each of your cameras are set up find the animation timeline at the bottom of the screen. This is what you will need to use to add the markers to the scene. 






To set up a marker select the frame that you want the camera to change on by either clicking on it on the timeline show above or by clicking on the box shown below and typing in your chosen frame number.



(Click on this box and then replace the numbers in the box with your chosen frame.)

Before you set any markers up it's always a good idea to set a marker on the first frame of your animation so that Blender knows which camera your animation starts with. Set your frame number to 1 and then hover your mouse over the green line and press "M". This should add a little yellow triangle on frame 1 as shown below.






Now you have the marker set up right click to select the camera that you want the animation to start with. With your camera selected click on the view button in the bottom left hand corner of the screen and click on the "bind camera to markers" option. Alternatively you can hover your mouse over the animation timeline and press Ctrl + B to bind the camera. 

















Once you've done this move to the frame that you want you're camera to change on by typing the number in the box shown previously. To add the second marker move your cursor down to the green line again and press M. This should add a second small triangle just like last time. 
















Right click on the second triangle to make sure that it's the only one selected. If both of the markers are orange Blender will bind the camera to both markers and the camera won't change when you want it to. With the second marker selected right click on the second camera in your scene and like you did with the first camera click on the view button in the very bottom left corner of the screen and click on the option that says bind camera to markers. This will bind your second camera to the second marker. Now you've bound the two cameras to the markers it would be a good idea to test to make sure that its worked . Set your animation frame to 1 and then press 0. This should change your view to the camera that you bound to the first marker. Press alt a to play the animation and wait to see if the camera changes when it reaches the second marker it means everything is working as it should be. 

Repeat these steps for any other cameras you might want to include in your scene and add cameras to your hearts content.

Video tutorial here:



As always any feedback is always appreciated on these tutorials, also be sure to tweet me @markimo2 with any troubles or further questions. 

Friday, 16 January 2015

Blender Tutorial: Rendering Text That Appears And Disappears In An Animation

Having text in an animation often helps tell the story or can be used to show interaction between characters in the scene. This short tutorial will show you the easiest way to keyframe your text so that it shows up when it is needed and disappears when it needs to.

First off start by adding your text to the scene and positioning it so that it can be seen by the camera. Press shift + A and add your text object to the scene. 
















Once the text is in the scene rotate the text by 90 degrees on the X axis by pressing "R" "X" "90". Now the text should look like it is standing up, use the move and rotate buttons (R and G) to move the camera around so that it can see the text. 
















Now that the text is in the camera view you will need to add the first keyframe to the text object, in the top right hand corner of the screen there is a list which shows you all of the items that are in the scene at the time.






















Somewhere on this list should be an item called "text" unless you renamed it to something different after adding it into the scene. On the far right hand side of this list there is a small camera icon, this icon controls whether or not the item is rendered in the scene. When the icon is solid as shown below the text will be rendered in the scene.





On the other hand if the icon is lighter as shown below the text won't be rendered.





To change this in your animation you need to set a keyframe for each of these states. To set these keyframes up you need to decide which frame you want the text to be rendered on. To change this you first need to select the frame you want by using the controls underneath the animation timeline at the bottom of the screen. 






Click on the box shown inside the blue outline above and delete the number, now replace this number with the frame number that you want to change your text object on. If you want your text to be rendered on this frame make sure the camera icon is solid as shown in the photo above and then right click on the camera and click on the insert keyframe option.























This will put a green circle around the camera icon. 







To change the text from rendered to un-rendered or vice versa use the controls at the bottom of the screen to change the number of the frame to the frame that you want the text to change on. When you've selected your frame left click on the camera icon and then right click again and click on the insert keyframe option to insert the second keyframe. 




























If you press Alt-A now to test your animation you won't see any change in the 3d viewport. To test to see whether or not this worked click on the render option next to file in the top left corner of the screen and click "Render Animation". As each frame renders watch to make sure that the text appears or disappears on the correct frame. 

This method of making things appear and disappear also works on normal meshes or models. Just follow these exact same steps and you should have no problems.

If you have anymore questions or anything in this tutorial doesn't work be sure to tweet me @markimo2 and let me know. 

Monday, 22 September 2014

Simple Movement Script In Unity (Javascript)

Movement is a key feature in many video games, without this we would have no way to explore the world that the developers have taken the time and effort to craft for us to enjoy. This tutorial will show you how to create a simple movement script for use in a 3D platformer, this script will show you how to move your character forward and backwards, left and right, make them jump and rotate around to look at the environment . The tutorial will feature the script written in  Javascript and will all be done using Unity. 

To start off with make sure that your player model has a rigidbody attached to it, this will ensure that when your character jumps they will drop back down to the ground and not float up in the air. Make sure that your character is selected in the project and then click on the "Component" option at the top of the screen. From the menu that pops up click on the "physics" option and then select "rigidbody" from the top of the next list that pops up. It will also be a good idea to put a tick in the "x" box next to the Freeze Rotation property to make sure that your character doesn't fall forward when jumping which could in turn cause problems with the script. 
















 Now this is set up you can move on to actually writing the code. 

To start off with lets deal with the forward and backwards movements for your character. Right click in your assets folder and create a new Javascript. After that double click on it to open it up. 

















At the top of the script there will be a small piece of text and symbols as shown in the example below.

















All of the code in this tutorial needs to be kept inside of the brackets that look like this { , } .
The first thing you need to do is set a speed for the movement of your character. Click on the empty space underneath where it says "#pragma strict" at the top of your script and write in the following piece of code:

var Speed : float = 0.3f;

Now this is all set up you can write the first piece of code to actually make your player do something. Click on the empty space in between the two strange shaped brackets and add in this next line of code:

if (Input.GetKey ("w"))
transform.Translate(Vector3.forward * Speed);

your code should now look something like this.













This piece of code will make your player move forward whenever the "w" key is pressed. If the speed is too fast for your liking feel free to change the value of the "Speed" variable that you added at the beginning of the tutorial. Now you have the forward control set up its time to add in the control to make your player move backwards, most of the code for this is the same as the previous code and there are only two pieces of the code that need to be changed. Click on the empty space next to the number 10 in your script and press enter. This creates a little bit of extra space on your script and at the same time makes it easier to read each new piece that you add. Click on the space next to the number 11 on your script and type out the same piece of code again but this time instead of writing "w" inside of the brackets change the w to an s and change the word "forward" to "back". Your script should now look like this:
















Drag and drop this script onto your player and then press play to test out your script, press the "w" key on your keyboard to move forward and the "s" key on your keyboard to move backwards.Once you've tested your script re-open it to add the next piece of code. The next thing you need to add is some way to look around with your character. The easiest way to achieve this is to create a control that makes your character rotate when a button is held down. Underneath the Speed variable at the top add a new variable with the name Rotate and give it a value like the previous variable. This variable will control how fast your player rotates around. Make an extra bit of space underneath the previous piece of code and add in the piece of code below: 

if (Input.GetKey ("a"))

transform.Rotate(0,0,Rotate);

You will probably notice that this piece of code is very similar to the previous pieces, there only a few small changes in this new piece of code. The most important one is the fact that the "Translate" has changed to "Rotate", this ensures that your player rotates when the button is held down. Once you've added the previous piece of code to your script your script should now look like this:




















Next up you need to add in a piece of code which will make your character rotate in the opposite direction. Again much like the code for the movement controls the next piece is much the same as the previous one with a couple of changes, take the previous piece of code but this time replace the "a" with "d" and instead of writing just Rotate put a - symbol in front of the word Rotate. Now when you hit play and hold down the "d" button your character will rotate clockwise instead of anti-clockwise. 

You're now pretty much done with this script and there is only one more thing to take care of which is your characters jump function. If we just add in a normal "transform.Translate" command the your character will still jump but if the button is pressed again whilst in the air your character will jump again and the jump will be unlimited, to stop this from happening you need to add in a boolean statement. This statement will work with another function in the script to make sure that the player can only jump when they are touching the ground. Scroll back to the top of the script where you added the previous variables and add the variable shown below: 

var JumpBool : boolean = true;

Now that the variable is set up you need to add a new function, this function will decide whether or not the player is touching the ground. Underneath the previous if statement make some space extra space and add in the function shown below:

function OnCollisionStay (collisionInfo : Collision)
{
JumpBool = true;
}

This function will decide whether or not the player is touching the ground when the jump button is pressed and set the boolean value to true. As well as this function you will also need to add another function which will set the boolean value to false when the player is off of the ground which will then disable the jump control and stop the player from being able to jump an unlimited amount of times. Make some extra space underneath the function that you just added and then add in the function below:

function OnCollisionExit (collisionInfo : Collision)
{
JumpBool = false;
}

Now these two pieces of code have been added your code should now look like this:






Now you have these two functions set up you can set up your characters jump control. The code for this control are written in much the same way as the rest of the keyboard controls shown in this tutorial. Start a new line underneath the previous "transform.Rotate" code and then type in this next piece of code: 

if (Input.GetKeyDown("j")

Notice that unlike that previous pieces of code that had the "GetKey" function in them this one doesn't have a second bracket at the end of it, this is because we need to add a little bit of extra code to this before it will work properly. After the bracket press the spacebar and add two "&" symbols in afterwards then hit the spacebar again and add in the piece of code below:

JumpBool == true)

Adding in this extra piece of code will complete this line of code and now means that whenever the "j" key is pressed the code will also check to make sure that the "JumpBool" variable you defined earlier is true. Now to add in the final piece of code, press enter to create a new line after you have added in the previous piece of code and copy the code shown below: 

transform.Translate(Vector3.up * 1);

Now that you've added in this code your player will jump when you press the "j" key as long as the player is touching the ground and the "JumpBool" variable is true. Now you've finished the script it should look like this:


























One important thing to note in this tutorial is to make sure that when you export your model from whatever 3D programme you are using is to check the axis of your model and make sure that the "Z" axis is the front of your model and the "Y" axis is the top of your model, this will make the forward, backwards and rotation controls work properly for your character.