Let's create a Game with Unity3D! Part 1

in #gaming6 years ago (edited)

Hello, I want to show you how you can simple create a Game with Unity Engine.

First of all we need to Download the Unity Engine you can find here.
Unity Engine

(On the Installer you should also install Visual Studio)

After you Install it you open your Unity Launcher and Create a new Game.
(Projects -> New)

You can enter any name you want i will call it for now "Steem".

Then you click on "Create project" after it you will see The main Unity Editor.

Now we create a Cube as Floor. You need to go to the left Window and select "Create"

->3D Object
->Cube

Then it should look like that:

After we done that we go to the right side and scale the Cube to became more floor like.

Now we Create another Cube which will be the Player:
You need to go again to left Window and select "Create"
->3D Object
->Cube

We will change now the Position and gave the Cube a name:

Now we go to the Down Window and create a C# Script.
Right Click->Create->C# Script
and call it "Player"

Now we make double-click on it and your C# Environment will open

We will now enter following Code with explanations:


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

//PlayerSpeed
public float speed = 5.0f;

//The Player Cube
private Transform player;

// Use this for initialization
void Start () {
    //Here we set the transform where the script is to our player variable..
    //In our case the Player
    player = transform;
}

// Update is called once per frame
void Update () {
    //Here we get the Axis input as variable (WASD or Gamepad). 
    //I will more explain it in another part!
    //The Axis input we * with our speed variable * Time.deltaTime
    // for smoother movements!
    float horizontal = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
    float vertical = Input.GetAxis("Vertical") * speed * Time.deltaTime;

    //Here we change the player positons with our variables
    //Vector3 means (X Axis, Y Axis, Z Axis);
    player.position += new Vector3(horizontal,0,vertical);
}

}


Now we save the code:

We are going back to our Unity Environment
where we select our Player Cube
and add our code by moving the Code into the Object:

Now we will click on Run!

That's it!!
You made your first Unity Player!

If you like the post, I would like you to follow me
and like my post that I continue my Unity tutorial :)

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 62868.73
ETH 3108.34
USDT 1.00
SBD 2.50