You are on page 1of 13

Game Programming Name: Aditya Rajguru

2022 - 2023 Roll No. 29

Index
Sr. No. Date Project Title Signature

1 28/07/2022 Create 3D object in Unity

2 28/07/2022 Apply Texture, Shader, Material to the object in unity

3 3/8/2022 Implement Collision Detection in Unity

4 8/08/2022 Creating Terrain in Unity

5 18/08/2022 Movement of an object in Unity

6 18/08/2022 Create Triangle in Unity

7 29/08/2022 Create a game for collision detection, movement and adding


the game objects in Unity

1
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 1

Aim: Create 3D Game Objects in Unity


How to change background color of main camera:

2
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

3
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 2

Aim: Apply Texture, Shader, Material to the object in unity

4
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 3
Aim: Implement Collision Detection in Unity

5
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

6
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 4
Aim – Create a Terrain

7
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 5
Aim – Adding movement (C# Script) to an object

8
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

W – Forward
S – Backwards
D – Right
A – Left
Code –
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour {


Vector3 Vec;
// Use this for initialization
void Start () {

// Update is called once per frame


void Update () {
if (Input.GetKey(KeyCode.A))
{
transform.Translate(0.1f, 0f, 0f);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(-0.1f, 0f, 0f);
}
if (Input.GetKey(KeyCode.S))
{
transform.Translate(0.0f, 0f, -0.1f);
}
if (Input.GetKey(KeyCode.W))
{
transform.Translate(0.0f, 0f, 0.1f);
}
Vec = transform.localPosition;
Vec.y += Input.GetAxis("Jump") * Time.deltaTime * 20;
Vec.x += Input.GetAxis("Horizontal") * Time.deltaTime * 20;
Vec.z += Input.GetAxis("Vertical") * Time.deltaTime * 20;
transform.localPosition = Vec;
}
}

9
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 6
Aim – Create Triangle in Unity
Create Empty from Hierarchy and name it Triangle then
create another create under the first and name it.

Code –
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Triangle : MonoBehaviour {

// Use this for initialization


void Start () {
gameObject.AddComponent<MeshFilter>();
gameObject.AddComponent<MeshRenderer>();
Mesh mesh = GetComponent<MeshFilter>().mesh;
mesh.vertices = new Vector3[] { new Vector3(0, 0, 0), new Vector3(0, 1, 0),
new Vector3(1, 1, 0) };
mesh.uv = new Vector2[] { new Vector2(0, 0), new Vector2(0, 1), new
Vector2(1, 1) };
mesh.triangles = new int[] { 0, 1, 2 };
}

// Update is called once per frame

10
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

void Update () {

}
}

OUTPUT-

11
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

Practical 7
Aim - Create a game for collision detection , movement
and adding the game objects in Unity
Conditions - Ball should move with keys ABCD
Scene -

Code -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour {


// Use this for initialization
void Start () {

// Update is called once per frame


void Update () {

12
Game Programming Name: Aditya Rajguru
2022 - 2023 Roll No. 29

if (Input.GetKey(KeyCode.A))
{
transform.Translate(0.1f, 0f, 0f);
}
if (Input.GetKey(KeyCode.B))
{
transform.Translate(-0.1f, 0f, 0f);
}
if (Input.GetKey(KeyCode.C))
{
transform.Translate(0.0f, 0f, -0.1f);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(0.0f, 0f, 0.1f);
}
}

Output -

13

You might also like