Download Unity 3d Snake Game Tutorial

Posted on

2D Snake Game Tutorial – Unity3D (C#), I will explain how to make a 2D Snake game in this tutorial. At first, open Unity and crate a 2D project. In this project, we are going to use 3 different image such as snake, food and border.

[Unity 5] Tutorial: How to create snake 3D in Unity - introduction - Duration: 1:53. Gamad 5,654 views. Unity Android Game Tutorial. Unity 2D Snake Tutorial. This Tutorial will explain how to make a simple 2D Snake Game in Unity. Snake is an arcade game that was. Download Source Code. 2d unity snake free download. Running on the unity game engine in which you have to follow Java code. Session), metacity, unity 3d, unity 2d.

So, create these images before start. Import these images and create surrounding borders from border image with names top, bottom, right, left. Place your snake image into the scene. Don’t forget to add Rigidbody 2D and Box Collider 2D(IsTrigger is checked).

Rigidbody scale of snake should be a little bit small than snake because we don’t want to hit snake to its tails. Create a C# script named Snake and attach it to your snake. Lets edit it. Firtsly, create public game objects.

Lets understand clearly all code. We created snake, food and borders. Snake moves with InvokeRepeating includes Movement. We create foods with SpawnFood function between the borders. Snake collects food with OnTriggerEnter by detect name of collider. You can add “else” in OnTriggerEnter after if statement to make that “if collider’s name is food, than collect it. Else, end game” which means if you hit borders or snake itself, end game.

Also you can manage score in OnTriggerEnter. You can download source code. – 2D Snake Game Tutorial – Unity3D (C#). I’m new in Unity (and programming in general) and I’m having a problem.

Nokia

The snake just doesn’t collide with the walls (and tail but I worry most for the former). UnassignedReferenceException: The variable BorderLeft of Snake has not been assigned.

You probably need to assign the BorderLeft variable of the Snake script in the inspector. // I just changed all the border names to my preference I’ve already put the borders on the Snake script in inspector. Instead of just: public Transform BorderTop; I tried adding: = new Transform; but it says: Assets/Snake.cs(11,54): error CS0122: `UnityEngine.Transform.Transform’ is inaccessible due to its protection level Still, the game is generally working with the Snake moving, eating, and growing properly!

2D Tetris Game Tutorial – Unity3D (C#) Do you remember the most famous single player game of early 90s? Yes, it’s Tetris. Developed by a Russian engineer, Aleksey Pajitnov, in 1985. Tetris is the 6th most played game ever.

We will make our Tetris game in this tutorial. The goal is to collect moving downward blocks at bottom with no gap in 2D.

Game ends when there is no available area for new block. Before start coding, please create or download your block texture (square) and wall texture.

You can find the on google or download images below. Open a 2D project in Unity3D and import these images. Cube images size is 32×32, so please edit Pixel Per Unit as 32 which means 32 pixels will be placed in 1 game unit. We need 7 different game object for blocks. Every block is created by 4 independent cubes because we will delete cubes separately when a row is full, not whole the object. By the way, we need J, T, S, Z, L, I, O-shaped blocks as you know. To create blocks, create an empty game object named BlockJ and create 4 cubes from cube image.

Assume that there is a 4×4 square and BlockJ is at the center (0, 0). Place cube objects in this 4×4 area. Be careful, you must placed cubes on squares perfectly to get best fit on game. You can see an example below. Place all cubes in block objects as seen as picture below. Create prefabs (create a Prefabs folder under Assets in Project window and drag blocks) and delete blocks in scene. We will check available area and restricted grid for cube movement, so you don’t need to add 2D collider to boxes and walls.

Create a C# script name SpawnBox and write code below. Create an empty game object and attach this code. New block will be created with position of empty game object. You can change position of empty game object where you want to create blocks.

Drag your 7 prefabs to boxList. Create another C# script named Boxes. Just remember the game rules, blocks move in grid(like snake but there are limits in this tutorial), we can move and rotate blocks, when we fill any row with full of cubes, that row should be deleted. This script will control valid positions, grid updates, rotate round and row actions. Lets write some code for grid and row operations. Mocha Post author As you see in the pictures, all Blocks are created by combining 4 small cube images.

This “cube” word doesn’t mean 3D because this tutorial isn’t 3D. You can get it as “square” if you want. Import the small cube image to Unity and just drag-drop to scene. You will see that a copy of the image will be created as a game object in scene. Do it 4 times and combine it to create a J-shaped object.

After that, create an empty game object and drag these 4 objects into it. By this, you get a parent object with 4 child objects. JamboxJosh nevermind, I see in attached scripts you’ve fixed. But honestly this tutorial is a mess most times your wording isnt clear and at the end of the tutorial there is no working game, your instructions are VERY unclear throughout with the last paragraph you rush through several important things w/o detail. By following this tutorial all I have is a screen where I can rotate 1 tetris piece and move it horizontally off screen not even close to a game.

I feel as if this was a waste of time. Vicky hello i am new in Programming. I just tried to make this game.

Your tutorial was really awesome and helpful. Thanks for this. And i am also looking for your some more amazing and awesome tutorials. So i have a problem please guide me.

I wanna increase speed of blocks downward. I tried many ways but can not do so. Please me where i have to change. “We use Transform grid so, we don’t need transform.position for blocks. It provides 1 unit move in 1 second. You can change it to change speed of blocks. Also, you can add score, time or colorful blocks in your game.” i cant understand this line please guide me.

I am waiting for your reply. Vicky hello i am new in Programming. I just tried to make this game. Your tutorial was really awesome and helpful. Thanks for this. And i am also looking for your some more amazing and awesome tutorials. So i have a problem please guide me.

I wanna increase speed of blocks downward. I tried many ways but can not do so.

Nokia 3d Snake Game

Please me where i have to change. “We use Transform grid so, we don’t need transform.position for blocks.

It provides 1 unit move in 1 second. You can change it to change speed of blocks.

Also, you can add score, time or colorful blocks in your game.” i cant understand this line please guide me. I am waiting for your reply. Thanks. Pingback:.

Pingback:.