Archive for Tutorial

Unity – Platforms

Example time.

You have began making a 2D platformer. But how are your platforms? Are they rigid, do they move. More importantly, do they have one way collision in most high class 2D platformers?

Well if your looking for one way collision platforms in Unity, i got some good news for you.

Here we will be looking into setting up such a platform.

There are a few ways to achieve this effect. One would be to use layers but that can lead you into problems. So here we will be usign a delegate system. The idea is that when the player goes from jumping to falling, each platform gets notified and checks whether to become “solid” or not based on whether or not it’s intersecting the player already.

To achieve this desired effect. We need to look into 4 main scripts.

  1. Player
  2. World
  3. Platform
  4. Includes

 

PLAYER.CS

new public static BoxCollider2D collider;

void Awake()
{
    collider = GetComponent<BoxCollider2D>();
void Update()
{
    if(jumping && velocity.y < 0f)
    {
        World.SetPlayerPlatformCollision(true);
    }
    else if(!jumping && Input.GetButtonDown("Jump"))
    {
        World.SetPlayerPlatformCollision(false);
    }
}

The Player script is pretty straight forward, we check for jumping and the velocity. However, the SetPlayerPlatformCollision method that is important. It is this that will tell the platform to toggle.

 

INCLUDES.CS

public class BoolEvent : UnityEvent<bool>{};

The Includes script is used just to contain one thing. The BoolEvent. Which tracks the status of a platform.

 

WORLD.CS

public static BoolEvent OnTogglePlayerPlatformCollision {get; private set;} 

static World()
{ 
    OnTogglePlayerPlatformCollision = newBoolEvent();
}

public static void SetPlayerPlatformCollision(bool collide)
{
    OnTogglePlayerPlatformCollision.Invoke(collide);
}

 

PLATFORM.CS

new BoxCollider2D collider;

void Start()
{
    collider = GetComponent<BoxCollider2D>();
    World.OnTogglePlayerPlatformCollision.AddListener(OnTogglePlayerPlatformCollision);
}

void OnTogglePlayerPlatformCollision(bool collide)
{
    collider.enabled = collide && !collider.bounds.Intersects(Player.collider.bounds);
}

The platform scripts checks wether the player has collided with the platform.

Hopefully this explains how it works, and arguably the best method of implementation.

Regards.

Press and Youtuber’s Information

Hello,

I thought i’d put together some tips on how I got kidnapped onto Steam Greenlight in just 5 days. So here goes:

1) create game to a given point – what i mean here is get your game working and up to a point where a demo could be put together, even if its just one level. This is optional, but if people can get hands on what your game is, the more connected they will feel.
2) get game registered over on IndieDB.com – this is a great place for people to find out about your game and since its a database of all indie games. Your’s should be there too.
3) get awesome screenshots, and a trailer. the better you get them, the better your chances, not just for steam, but for journalists to take notice.
4) register on gamespress.com and create a professional press release. For more information on how to create a fantastic press release can be found at http://www.indiegamegirl.com/press-release-template/
5) Create a landing page for your game. I created www.kidnapped-game.com. please review it for reference.
6) about 1 month before you put your game on steam greenlight send out the initial press release to gamespress.com. stating what the game is, specs and a write up about the story or game play.
7) wait a little while for peopl;e to hear aboyt the game and then register as a Greenlight developer (can be seen as pricey) and create your page.
8) Once the game is on Greenlight, send out another press release stating its now on Greenlight.
9) once complete, don’t stop there, you will need to get the news to as many people as possible. I literally spent hours looking over indie game sites looking for contact information so i could also send them the press release.

You might be thinking, that’s a lot of work just to get on Steam Greenlight. But hey, it worked, and it worked well. I learnt a lot from the experience and i suggest you all to give it a go, and give it your all. After all, if you want success, you need to push everything to its limit.

I have also decided to help you all out. I am going to put up over the course of the next few months, the contact information that i have gathered, starting now… (this is an excel file)

You lucky people.

I really hope it can help some people get noticed.

And don’t forget to add me on twitter @deceptive_games  and  @klarax.

[note: if any game journalist on this list does not want to be on it, please email info@deceptive-games.com and i will remove it from the date i receive your email]

Many thanks

Gavin Powell
@klarax
Deceptive Games

[ link: https://www.dropbox.com/s/uzxo0vzxltpqjxq/press%20stuff.xlsx ]

(any issues downloading file, email info@deceptive_games.com)

Unity useful tips and tricks

Hello,

We have been using Unity for quite some time now and although its a fantastic piece of software for developing games, there are a number things that can hinder your development time. This post hopes to remedy this and help everyone who uses Unity; from beginner to advanced.

If you want to add colliders, but are annoyed by the 0.01 import scale this is a handy little bit of code

using UnityEditor;
public class FBXScaleFix : AssetPostprocessor
{
public void OnPreprocessModel()
        {

                ModelImporter modelImporter = (ModelImporter) assetImporter;                    
                modelImporter.globalScale = 1;        
                modelImporter.addCollider = true;
                modelImporter.normalImportMode = ModelImporterTangentSpaceMode.Calculate;
        }  
}

Naming Principles

  1. Use short names, and proper names. Call it what it is; a car would be Car.
  2. Choose names that are simple and can be spelt. Keep it simple
  3. Be consistent. This is for both naming convention and names.
  4. Do not use spaces, underscores, or hyphens if possible.
  5. Do not use abbreviations: InfantChild should NOT be infChild.
  6. Keep the most specific descriptor on the left: SelectButton, not SelectPaused. Its easier to find the word Select than searching the word button.
  7. At times when you have multiple items of the same name start at 0 not 1
  8. Use different words for different item types. Use Cup, Mug, Beaker instead of cup1, cup2 etc
  9. To find important items in the scene, use $ at the beginning of the name, so it always appear at the top of the scene hierarchy.
  10. It is good practice to name temporary objects with a double underscore __Bullet.

A god trick going around that maybe people have yet to hear is to use underscores between the core names. For example:

  • Texture: Chair_Diffuse and Chair_NormalMap
  • Skybox: TownSky_Top and TownSky_North

Other General Stuff

  1. Make sure function names are spelt correctly. They wont show an error.
  2. OnTriggerEnter and OnTriggerExit use COLLIDERS.
  3. OnCollisionEnter and OnCollisionExit use COLLIDERS.
  4. Put all pivots on the bottom of the prefab, this makes it easier to move around in the sceneview.
  5. On Creating a GuiTexture whilst having a 2D texture selected in the ‘project pane’ will automatically use that texture (instead of the default Unity Logo) and correctly set up the pixel inset values.
  6. Cameras in Unity can have their own skybox via adding the skybox component to any camera.
  7. Cubemaps are never compressed in vram (ARGB32) (standalone/web player), for skyboxes you are better off using 6 compressed textures if memory is an issue.
  8. Use [ ] around important gameObject names or append an underscore to the beginning to place them at the top of the hierarchy.
  9. Holding down “Ctrl” you can drag an object block at a time (like a snap feature).
  10. Select the camera in the hierarchy then GameObject -> Align With View. This will put the game camera at the location of the scene view cam
  11. Select the main camera then GameObject -> Align view to selected to move the scene camera to the position of the main camera
  12. Create a material with the shader you want to use highlighted in the project browser it will use the selected shader by default.
  13. FBX Scale & Automatically add colliders 🙂
  14. Delete inspector array items (like the input manager) by clicking on the item and pressing cmd/control & delete
  15. You can insert into inspector array items by selecting an item and hitting cmd/control & d to duplicate it.

 

For further information and tricks, check out JasperStocker

Credits Complete

Credits and a Little Instructional Guide

Hello,

I thought i d put up a quick little guide on how i achieved the effect of performing the ending credits within Kidnapped.

Firstly, i had to create some textures for the each screen that would be shown. These textures are saved as .pdf file so it maintains what i created within Photoshop. But as long as the texture contained an alpha channel, it would still work.

Some examples of the credit textures can be seen below:

credits

In unity a material was created for each texture and then i went about setting up the scene.

The scene comprised on one camera, one cube and a directional light facing the cameras side of the cube.

I placed a few components on the cube: 2 AudioSources (one for the music and one for the impact sound as soon as the scene started). This cube also contained a script that i wrote that changed each material over a give time.

See below the screenshot of the scene in its final form.

credits in unity
The last thing to do was on the fade the final material’s alpha channel and any AudioSource’s that were playing so it gave the impression of complete end.

The scene took around 2 hours to complete from start to finish, and this was in-between making tea and other household chores. If you have any questions on how i completed this, or possibly help. Please use the comment section below. I am more than happy to help.