Professional Documents
Culture Documents
3
Mapped CO : CO4 Demonstrate an understanding of various tools that are used in game
development
Experiment 7: Moving, rotating & scaling Game objects and in Unity and Add colors, textures,
Parent and child to Game object.
UID: 20BCG1014
AIM:
Moving, rotating & scaling Game objects and in Unity and Add colors, textures, Parent and child to
Game object.
TASK TO BE DONE:
In this experiment we have to create GameObjects on Unity. We have to add color/textures and
movement to the objects.
SOFTWARE USED:
Unity, VS Code.
PROCEDURE:
1. Create a new project.
First, you have to open the Unity project. Create the Plane for your game.
Click on the "GameObject" menu in the menu bar. Select 3D objects and pick the "Plane" option.
Click on the "GameObject" menu in the menu bar. Select 3D objects and pick the "Cube" option.
We create material assets of two different colors and add it to the objects.
A. (Jump,Horizontal,Vertical)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Vector3 Vec;
void Start()
void Update()
Vec = transform.localPosition;
Go back to the Unity window. Drag and drop the move script onto the cube.
Press "Up Arrow" Key, and the Cube will move in a forward direction.
Press the "Left Arrow" Key, and the Cube will move to the left.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
if (Input.GetKey(KeyCode.UpArrow))
this.transform.Translate(Vector3.forward * Time.deltaTime);
if (Input.GetKey(KeyCode.DownArrow))
this.transform.Translate(Vector3.back * Time.deltaTime);
if (Input.GetKey(KeyCode.LeftArrow))
this.transform.Rotate(Vector3.up, -10);
}
if (Input.GetKey(KeyCode.RightArrow))
this.transform.Rotate(Vector3.up, 10);
Press "Left & Right Arrow" Key, and the Cube will Rotate to the left and right.
Fig. 11. Object moved backward. Fig. 12. Object moved forward.
C. Move the object by using keys W,A,S and D.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Start()
void Update()
if (Input.GetKey(KeyCode.A))
if (Input.GetKey(KeyCode.D))
if (Input.GetKey(KeyCode.S))
{
transform.Translate(0.0f, 0f, -0.1f);
if (Input.GetKey(KeyCode.W))
Press “D” key. The object will move to the right side.
LEARNING OUTCOMES: