Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Out Of Box Tutorial | Unity Game Engine | By Mayank ,VIT-Bhopal

A topic by night05fury created May 07, 2021 Views: 233
Viewing posts 1 to 1

This tutorial is made as a part of my Game Programming Course at VIT-Bhopal. 

Mayank Kumar Patel -20BCG10035 

Hope you liked it , feedbacks are welcomed.

https://youtu.be/eOr2b7gzw2w

Scripts Used in this tutorial are below

Moving Script

using System.Diagnostics;

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Debug = UnityEngine.Debug;

public class movebyKeyboard : MonoBehaviour

{

    // Start is called before the first frame update

    float movespeed = 5f; //to increase the movement speed 

    void Start()

    {

        PrintInstructions();

    }

    // Update is called once per frame

    void Update()

    {

        MovePlayer();

    }

    void PrintInstructions()

    {

        Debug.Log("Use arrows keys to move the objects around");

    }

    void MovePlayer()

    {

        float xvalue = Input.GetAxis("Horizontal")* Time.deltaTime * movespeed; //timedelta time is used to make it frame independent

        float zvalue = Input.GetAxis("Vertical")* Time.deltaTime * movespeed;

        transform.Translate(xvalue,0,zvalue);

       

    }

}

Object Hit

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Debug = UnityEngine.Debug;

public class ObjectHit : MonoBehaviour

{

    

    // Start is called before the first frame update

    private void OnCollisionEnter(Collision other) 

    {

        if(other.gameObject.tag == "Player")

        {

            GetComponent<MeshRenderer>().material.color = Color.red;

            gameObject.tag = "Hit";

        }

        

    }

}

Spinner Script

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Spinner : MonoBehaviour

{

    // Start is called before the first frame update

    [SerializeField] float xAngle=1 , yAngle=1 , zAngle=1 ;

    void Start()

    {

        

    }

    // Update is called once per frame

    void Update()

    {

        transform.Rotate(xAngle, yAngle,zAngle);

    }

}