Skip to main content

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

night05fury

3
Posts
1
Topics
2
Followers
3
Following
A member registered Apr 08, 2021

Recent community posts

Thanks

thanks bud

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);

    }

}