Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

FINAL TERM

Subject Game programming

Course Instructor: Madam Momina Masood


Total Marks:
Issue Date: 10-02-2021
Submission Date: 10-02-2021

Registration# Name
Submitted by:
18-CS-16 Laiba Fatima

Obtained Marks:

Ques no 2:

1
Part(a):Demonstrate the difference between:

1: Differentiate between screen space overlay and screen space camera.


Ans: Screen Space Overlay: UI elements are provided on top in screen space overlay. In this
overlay screen is filled and resized if needed by canvas perpetually.
Screen Space Camera: In screen space camera UI elements are provided at a defined distance
from the camera and it's settings e. g projection etc. It affect the way elements are provided.

2: Animation tree vs blend tree:


Animation tree: If we want a complete hold on animation blending and it's play back process
then animation state is used. It's interface allows us to change time, speed, layers and weight etc
in a playing scene. WrapMode and setup animations can be used.
Blend tree: Animations can be blended together by using variables in it. It's usually used in
character movement. Its similar to simple animation tree. In simple animation you proceed in one
animation and pass to another animation.

3: Raise/lower tool vs paint height tool:


Raise/lower tool: By using this tool the height can be increased by moving mouse on terrain and
piled up if we hold the mouse on a point and is familiar to airbrush's effect in image editor.
Different effects are created by different brushes.
Paint Height tool: It is much familiar to raise lower tool except having an additional tool which
can set targeted height. Terrain is decreased in the areas above the object which is being painted
and increased in areas above it. Height can be modified by height property slider manually or by
a shift click to set height upto mouse's position on terrain.( like the eyedropper in image
editor ).After this there is a flatten button. It's task is to settle the terrain upto selected height.
This tool is helpful to settle raised ground level. e.g: hills and velleys are adjusted above and
below landscape.

4: Screen space vs view port space:


Screen space: It's a 2D area having origin in lower left corner and have equal size upto our
resolution.
Veiw port space: It's a normalized area from (0,0) to (1,1).

5: Directional light vs sky box:


Directional lights: These are helpful for making impacts, for example, daylight in your scenes.
Carrying on from multiple points of view like the sun, directional lights can be considered as far
off light sources which exist vastly far away. A directional light doesn't have any recognizable
source position thus the light item can be set anyplace in the scene. All items in the scene are
enlightened as though the light is consistently from a similar bearing. The distance of the light
from the objective item isn't characterized thus the light doesn't reduce.
Skyboxes: These are a covering around your whole scene. Think about every special Scene
record as a one of a kind level. In every Scene, you place your surroundings, hindrances, and
adornments, basically planning and building your game in pieces.

Part(b):Describe functionality of unity animation layers…?


Solidarity utilizes Animation Layers for overseeing complex state machines

for various body parts. An illustration of this is on the off chance that you have a lower-body
layer for strolling bouncing, and a chest area layer for tossing objects/shooting.

You can oversee activity layers from the Layers Widget in the upper left corner of the Animator
Controller

Tapping the stuff wheel on the privilege of the window shows you the settings for this layer.

On each layer, you can indicate the cover (the piece of the energized model on which the
activity would be applied), and the Blending type. Abrogate implies data from different layers
will be disregarded, while Additive implies that the activity will be added on top of past layers.

You can add another layer by squeezing the + over the gadget.

The Mask

property is there to indicate the cover utilized on this layer. For instance on the off chance that
you needed to play a tossing movement on the chest area of your model, while having your
character additionally ready to walk, run or stop simultaneously, you would utilize a veil on the
layer which plays the tossing liveliness.

Ques no 3:

Part (a): Consider a scenario where an animator ….?


Ans:
/Attach this script to a GameObject with an Animator component attached.
//For this example, create parameters in the Animator and name them “Crouch”
and “Jump”
//Apply these parameters to your transitions between states
//This script allows you to trigger an Animator parameter and reset the
other that could possibly still be active. Press the up and down arrow keys
to do this.

using UnityEngine;

public class Example : MonoBehaviour


{
Animator m_Animator;

void Start()
{
//Get the Animator attached to the GameObject you are intending to animate.
m_Animator = gameObject.GetComponent<Animator>();
}

void Update()
{
//Press the up arrow button to reset the trigger and set another one
if (Input.GetKey(KeyCode.UpArrow))
{
//Reset the "Crouch" trigger
m_Animator.ResetTrigger("Crouch");

//Send the message to the Animator to activate the trigger parameter named
"Jump"
m_Animator.SetTrigger("Jump");
}

if (Input.GetKey(KeyCode.DownArrow))
{
//Reset the "Jump" trigger
m_Animator.ResetTrigger("Jump");

//Send the message to the Animator to activate the trigger parameter named
"Crouch"
m_Animator.SetTrigger("Crouch");
}
}
}

Part (b): As soon as player enter a …?

Ans:

Part (d) Consider a scenario where enemy appear from top center of the screen,
and as soon as they reach

the center of the screen they start moving in a circle.

Ans:
(d)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Q3Partd : MonoBehaviour


{
Camera camraObject;
public Quaternion rotatingCoords;
public Vector3 transformation;
double currentRotation = 0.0;
double radius = 5.0;

void Start(){
camraObject = GameObject.
FindGameObjectsWithTag("camraObject");
}

private void Awake() {


Vector3 centerPos =
Camera.
main.
ViewportToWorldPoint(
new Vector3(0.5f, 0.5f, distanceFromCamera)
);

rotatingCoords = this.rotation;
transformation.Set(5, 0, 0);
}

void Update(){
if(
Vector3.
Distance(
this.transform.posotion,
camraObject.transform.position
) == 0
){
enemyRotation();
}
}
enemyRotation(){
currentRotation += Input.GetAxis("Horizontal") * Time.deltaTime * 100;
rotatingCoords.eulerAngles = Vector3(0, currentRotation, 0);
transformation.position = rotatingCoords * radius;
}
}

You might also like