0% found this document useful (0 votes)
52 views1 page

Unity C Sharp Primjer

The document contains code for two C# scripts in Unity - GameController.cs and Player.cs. GameController.cs logs messages to the console when the space or left arrow keys are pressed. Player.cs controls the movement of a player object, allowing it to move left, right, and up via keyboard inputs by changing its transform position over time based on the speed variable.

Uploaded by

Damir K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
52 views1 page

Unity C Sharp Primjer

The document contains code for two C# scripts in Unity - GameController.cs and Player.cs. GameController.cs logs messages to the console when the space or left arrow keys are pressed. Player.cs controls the movement of a player object, allowing it to move left, right, and up via keyboard inputs by changing its transform position over time based on the speed variable.

Uploaded by

Damir K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 1

using System.

Collections;

using UnityEngine;

public class GameController : MonoBehaviour


{

// Use this for initialization


void Start () {
Debug.Log ("Hello world");
}

// Update is called once per frame


void Update () {
if (Input.GetKey("space"))
{
Debug.Log("Jump");
}
if (Input.GetKey("left"))
{
Debug.Log("Move left");
}

}
}

POMAK KOCKE LIJEVO I DESNO

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

public class Player : MonoBehaviour {


public float speed = 3.5f;
// Use this for initialization
void Start () {

// Update is called once per frame


void Update () {
if (Input.GetKey("right"))
{
transform.position += Vector3.right*speed*Time.deltaTime;
}
if (Input.GetKey("left"))
{
transform.position -= Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey("up"))
{
transform.position += Vector3.up * speed * Time.deltaTime;
}
}
}

You might also like