Wednesday 28 December 2016

Create simple android platform runner game on unity Create simple android platform runner game on unity


Create simple android platform runner game on unity

Create simple infinite runner game on unity

Hello today we will create simple platform runner game on unity.

In This post we will create game and creating it for android. This game is simple 2d game and very funny and it will be developed on unity … my favorite game engine


We are going to create platform runner android game on unity . in our Platform runner game our hero will when clicked on the screen or on mobile devices Touched on the Screen …
People love to play platform runner game and we are going to create it

Creating platform runner android game on unity it is not so easy but I will make it easy only for you

Please share this blog post with your friends if I will get more users then I will post more tutorials




Download the images for creating animation

Recently we just discussed about how to create animation on unity for game if you missed this article then you can go to this linkClick Here



Lets Start our game work . We are going to create simple platform runner game and we will make it for android


In this post we will make our hero to jump on the platform ….

Our First Work is To Make Our camera To orthographic This can be done by select main camera and after selecting you will see on inspector window “Projection change it to orthographic”

Our first work is done…..


Now We Will start The work of creating game… This can be start by creating our hero to the unity …

For this you will require assets the all assets are from open game art …. You can download it by searching on Google…

You can use this assets on your android game for free


Now we will create animation for game…

Now we will start creating our game we will first create our hero . To creating hero we need an image here I used images from open game art website
First all three images change texture type to “Sprite”
Texture type can be changed by selecting each image and on inspector window you will see texture type option just change it by “sprite”

Now we will create animation …. So How to Create Animation you already know.

If you don’t know then go to this link

Recently we just discussed about how to create animation on unity for game if you missed thChanis article then you can go to this link click Here


For crating animation just select all the images and pest it on hierarchy window Your animation ready for use ….

Now we will start scripting …


First we will create script for movement of our camera

Now Right Click on your assets window then create then C# Script and name the Script as CameraMove Now Open the Script ….

And pest this code using UnityEngine;
using System.Collections;
public class CameraMove : MonoBehaviour {
float camaraZ ;
void Start () {
camaraZ = transform.position.z;
} public Transform player;
// Update is called once per frame
void Update () {
transform.position = new Vector3 (player.position.x + 0.5f, 0, camaraZ);
}
}










Here our script is Ready …. For our Camara …


Here We used variable transform player … By using this variable we specify our game object…

We will provide a hero game object to it ….

Now our camera script is ready for use on unity …so drag this script from assets and drop it on hierarchy windows main camera game object …our half work is completed.


We will create our hero ….


Now delete the animation from hierarchy window …. Don’t delete from assets.

Now Right click on the hierarchy window and create empty game object and name it as Hero.

Now drag the animation which is you already created and drop it on the hero game object on hierarchy window.

Now Select hero and then click on add component and then add rigidbody2D

And again add another component sprite render.

And drag one image of hero from assets and drop it on Sprite renders as shown on image

Now Select hero and on inspector window change scale to x=3 ,y= 3 and z=3

Now Select main camera on inspector window you will see script then drag the hero game object from hierarchy and past on the player as shown on image


Now We will Create ground and sealing


Right click on” main camera” and create empty game object and name it as upper

Add component add box collider 2d

Make the scaling as shown on image.

Add ground … right click on main camara then click on create empety then name as ground and add box collider component

Make changes as pos x=0,y=-5.5,z=0 scale x=13,y=1,z=1


Create Script for hero movement on android game on unity


You are reading article on create infinite platform runner game on unity…

Right click on assets and create script c# using UnityEngine;
using System.Collections;
public class HeroMovement : MonoBehaviour {
float xspeed = 1.5f;
void Start () {
}
// Update is called once per frame
void Update () {
MoveOnXAxis();
if (WasTouchedOrClicked())
{

}
}
bool WasTouchedOrClicked()
{ if (Input.GetButtonUp("Jump") || Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Ended)) return true;
else
return false;
}
void MoveOnXAxis()
{
transform.position += new Vector3(Time.deltaTime * xspeed, 0, 0);
}
void BoostOnYAxis()
{ //GetComponent().velocity = new Vector2(0, VelocityPerJump);
GetComponent().AddForce(new Vector2(0.3f,50f));
}
}



























Add box collider 2d component to the hero



Select Rigid body component of our hero and change gravity to 0.1

Our Work is completed …. Hit on play button you will see hero is moving…..On Next post we will add platforms to the game then our hero can jump …
This is Create simple platform runner game on unity…
Just visite second article of how to create simple android platform runner game on unity click here We will Create infinite platform runner game for android and unity …
If you have any question about related with this post then please comment
In this post we just created hero and make hero movable …

Wait for new post … please comment please share this post with your friends Thank you ….

































































































No comments:

Post a Comment

how to make money from Amazon

How To make money from Amazon Hello friends today we are going to know how to make money from Amazon. In this tutorial we are going to st...