Professional Documents
Culture Documents
Code 2nd Level License in Informatics - Specialization: Multimedia and Web Development (MDW)
Choose the one-and-only correct answer. Do not rewrite it, just indicate the couple (number, letter):
1) A 256px squared Sprite of a flying bird has 12 frames laid out with 3 frames Vertically
and 4 Horizontally. How to slice it correctly in the Sprite Editor?
A. Set Type to Grid By Cell Count Set Column & Row to C4 R3
B. Set Type to Grid By Cell Size Set Pixel Size to X64 Y84
C. Set Type to Grid By Cell CountSet Column & Row to C3 R4
D. Set Type to Grid By Cell SizeSet Pixel Size to X84 Y64
2) We have several city buildings that are textured and will not move in the Scene. In order
to optimize the draw calls of their textures, which Static option is to choose?
Surveillants A. Batching
Signatures B. Off-Mesh Links
……………… C. Lightmapping
……………… D. Navigation
……………… 3) We use Cinemachine to create Blend List Camera. We want to slowly ease out from the
……………… first Virtual Camera then linearly enter the second Virtual Camera. What Blend In setting is
………………
to use?
………………
A. Linear
………………
B. Cut
……………… C. Ease Out
……………… D. Hard In
……
4) Using Curves view in the Timeline Clip, we want to animate a bouncing ball from the
ground. Th e ball jumps and stands a bit on air then gets down. After
adding 3 keyframes to the Y position Curve, what Interpolation Mode
is to choose for keyframes to get the ball standing in the air?
Corrector A. Auto
Signature B. Flat
C. Clamped Auto
……………… D. Free Smooth
………………
5) We imported two fighters having animations attached to them. We need to use Mecanim
………………
to create some new animations for them. When importing their FBX files, which animation to
………………
choose?
……………….
A. Humanoid
…
B. None
C. Legacy
D. Generic
Page 1 of 7
Write Nothing In Here
6) We created a Blend Tree to control our D. Window > General > Services
character’s facial animations. We need to set 10) Using Cinemachine, we set up a Virtual
the weight of each node to a specific value. Camera for a 2D side scrolling game and want
Which Blend Type should the Artist use for the camera to only show the area delimited by
this Blend Tree? a given 2D Box Collider. What Virtual Camera
A. 2D Simple Directional to choose?
B. 2D Freeform Cartesian A. Cinemachine Impulse Listener
C. 1D B. Cinemachine Follow Zoom
D. Direct C. Cinemachine Collider
7) We have a script to change our D. Cinemachine Confiner
character’s animation according to his speed.
11) An Artist has set the Texture Type to
The speed is forwarded to a parameter called
CharacterSpeed on the characters Animator Sprite(2D and UI) in an images Import
Settings. What is the other setting that should
component, we play a different animation.
be set when preparing a Sprite Texture for 9-
What Parameter Type is to choose for
CharacterSpeed in the Animator? Slicing?
A. Set Mesh Type to Full Rect
A. Trigger B. Set Sprite Mode to Multiple
B. Bool C. Set Extrude Edges higher than 1
C. Int D. Set Pivot to Custom
D. Float 12) An Artist is adding a Canvas to hold
8) We are using Cinemachine to set up a some UI components for a VR application.
Virtual Camera for a game with a top down What Render Mode should the Artist use for
perspective view. The Virtual Camera should the best UI experience in VR?
be able to follow a moving car and accept A. Screen Space - Overlay
mouse input. To accomplish this, what should B. World Space
C. Screen Space - Camera
the Artist set the Virtual Cameras Body
property to? 13) We have a script that will display an
A. Framing Transposer animated Sprite of a key when the user
collides with a 3D model of a key in the scene.
B. Tracked Dolly
The user should not be able to click on or
C. Orbital Transposer interact with the Sprite. The script has a
D. Hard Lock To Target variable for the key Sprite. Then the Artist
9) We want to use Unity’s Cloud Build with needs to connect in the Inspector to a UI
Collaborate. What Window in the editor shoul component in the Hierarchy. What type of UI
we open in order to enable Cloud Build? component should the player use to
A. Window > Analysis > Profiler accomplish this?
A. Image
B. Window > Asset Management > Colab B. Button
History C. Canvas Renderer
C. Window > Package Manager D. Raw Image
Page 2 of 7
II. 3D programming of a game in Unity (12.5 pts)
We will create a game where a sleeping little boy (or girl)
that we control, will fight some toys using given arms. This
is a Survival Shooter game that take place in the child’s
room as given in the figure blow.
void Update () {
if (pauseMenu != null && Input.GetButtonDown("Cancel")) A reference to a
pauseMenu.Pause(); function that hands the
if (!CanUpdate()) movement of the
return;
character
HandleMoveInput(); 3
HandleAttackInput(); 4
HandleAllyInput();
} A reference call to a
bool CanUpdate() { function that handles
if (pauseMenu != null && pauseMenu.IsPaused) the Attack behaviors
return false; for the character
Page 3 of 7
if (GameManager.Instance.Player == null || (GameManager.Instance.Player.transfor
m != transform)
return false;
return true; // the inverse case
}
void HandleMoveInput() {
if (playerMovement == null) Detects if the mouse
return; has been clicked and is
float horizontal = Input.GetAxisRaw("Horizontal"); in a valid location
float vertical = Input.GetAxisRaw("Vertical");
playerMovement.MoveDirection = new Vector3(horizontal, 0, vertical);
if (MouseLocation.Instance != null && MouseLocation.Instance.IsValid) { 5
Vector3 lookPoint = MouseLocation.Instance.MousePosition - …………………………………………………………
…… ;
playerMovement.LookDirection = lookPoint;
} Detects if the input
} type related to the
void HandleAttackInput() { “Fire” behavior has
if (playerAttack == null) been called in the
return; Unity engine
if (Input.GetButtonDown("SwitchAttack")){
playerAttack.SwitchAttack();
} Applies the Fire()
if (Input.GetButton("Fire1")){ 6 function relative to
playerAttack.Fire(); 7 the instance named
} “playerAttack()”
else if(Input.GetButtonUp("Fire1")) {
playerAttack.StopFiring ();
}
}
void HandleAllyInput() {
if (Input.GetButtonDown("SummonAlly") && (playerMovement.transform.position != nul
l)
(GameManager.Instance.SummonAlly();
}
}
Page 4 of 7
A static reference
public class GameManager : MonoBehaviour variable named
{ “Instance” a unique
variable for the
public static GameManager Instance; 1
“GameManager” class
[Header("Player and Enemy Properties")]
public PlayerHealth Player;
public Transform EnemyTarget;
[SerializeField] float delayOnPlayerDeath = 1f;
[Header("UI Properties")]
[SerializeField] Text infoText; // show info to player The GameObject is
[SerializeField] Text gameoverText; referenced by the private
[Header("Player Selection Properties")] variable “enemySpawner”
[SerializeField] GameObject enemySpawners; 2 in the code and is
[SerializeField] Animator cameraAnimator; visible in the inspector
[Header("Ally Properties")] thanks to the
“SerializeField” mention
[SerializeField] AllyManager allyManager;
int score = 0;
void Awake(){
if (Instance == null)
Instance = this;
else if (Instance != this)
Destroy(this);
}
public void PlayerChosen(PlayerHealth selected){
Player = selected;
EnemyTarget = Player.position;
if(infoText != null)
infoText.text = "A sample init Text";
if(enemySpawners != null)
enemySpawners. SetActive(true) ; // Among many other possible anwsers
if(cameraAnimator != null)
cameraAnimator. Play ("Start");
}
public void PlayerDied(){
EnemyTarget = null;
if(gameoverText != null)
gameoverText. enabled= true;
}
public void PlayerDeathComplete(){
Invoke("ReloadScene", delayOnPlayerDeath ); // this variable is predeclared
}
public void AddScore(int points){
score += 1;
if (infoText != null)
infoText.text = "Score: " + score.ToString();
if (allyManager != null)
allyManager.AddPoints(points);
}
public void SummonAlly(){
if (allyManager == null)
return;
Ally ally = allyManager.SummonAlly();
if (ally != null){
EnemyTarget = ally. position;
Invoke("UnSummonAlly", ally.Duration);
}
}
Page 5 of 7
void UnSummonAlly(){
EnemyTarget = Player. position;
allyManager.UnSummonAlly();
}
void ReloadScene(){
Scene currentScene = SceneManager.GetActiveScene();
SceneManager.LoadScene(currentScene );
}
}
II.3. Completing the enemies Spawning (dispersion) in the scene: (2.5 pts)
In our ZombieToys scene, we have placed a number of 3D empty gameObjects that will be used as points of
apparition for the enemies. Thys will be instantiated and spawned out of these positions. You are asked to complete
the following script in order to:
II.3.1. Create a number of instances variable named maxEnemies and another variable spawnRate that
controls the rate of their apparition in the scene.
II.3.2. Since the start of the game, create an array table that will hold the enemies list but they will be
deactivated and so, non-visible in the scene yet.
II.3.3. Make a loop on all the enemies and make them visible using the method SpawnEnemy
public class EnemySpawner : MonoBehaviour
{
[Header("Spawner Properties")]
[SerializeField] GameObject enemyPrefab;
[SerializeField] float spawnRate;
[SerializeField] int maxEnemies;
[Header("Debugging Properties")]
EnemyHealth[] enemies;
void Awake(){
enemies = new EnemyHealth[maxEnemies];
• Typcal Script C#
using UnityEngine;
using System.Collections;
public class BasicTargetMover : MonoBehaviour {
void Start () {// Initialization
}
void Update () {// Mise à jour de la scène
}
}
• Vectors
public Vector2 loc = new Vector2(float x, float y);
public Vector3(float x, float y, float z);
public Vector4(float x, float y, float z);
• 3D primitives
//Exemple de creation de Quad
GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Quad);
//PRIMITIVES: Sphere, Capsule, Cylinder, Cube, Plane, Quad
• Components
//Ajout:
SphereCollider sc = gameObject.AddComponent<SphereCollider> ( ) as SphereCollider;
//Accès
HingeJoint hinge = gameObject.GetComponent<HingeJoint>();
• Transformations
//Exemple de modification de position:
transform.position = new Vector3(0, 0, 0);
//Modification de rotation en quaternions :
public void Rotate(Vector3 eulerAngles);
//Exemple de modification d’échelle:
transform.localScale += new Vector3(0.1F, 0, 0);
• Instanciation
GameObject spawnedObject = Instantiate (prefabObject, spawnPosition, spawnRotation) as
GameObject;
Page 7 of 7