Search test library by skills or roles
⌘ K

Adaface Sample Unity Questions

Here are some sample Unity questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

SO Application
ScriptableObjects
Data Management
Performance Optimization
Solve
Consider the following Unity3D scenario where you are tasked with optimizing a game's configuration settings using Scriptable Objects for data-driven design. Examine the given ScriptableObject script and answer the question: How can you ensure that data from multiple Scriptable Objects are properly aggregated and utilized at runtime without creating unnecessary instances?
using UnityEngine;
            
            [CreateAssetMenu(fileName = "GameConfig", menuName = "Configurations/GameConfig")]
            public class GameConfig : ScriptableObject {
                public string configName;
                public int maxEnemies;
                public float enemySpawnRate;
            
                public void DisplayConfig() {
                    Debug.Log($"Config: {configName}, Max Enemies: {maxEnemies}, Spawn Rate: {enemySpawnRate}");
                }
            }
Options:
            A: Use static variables in ScriptableObject for data access
            B: Instantiate ScriptableObjects on script load
            C: Reference ScriptableObjects in MonoBehaviour scripts using Inspector
            D: Load all ScriptableObjects at runtime using Resources.Load
            E: Use a Singleton to manage ScriptableObject instances
            F: Merge data manually during runtime in a central manager

Medium

Prefab Instantiation
Prefabs
Instantiation
Scripting
Solve
You are tasked with creating a system that spawns enemies in Unity3D using prefabs. The prefab `EnemyPrefab` has a script attached, `EnemyBehavior`, which contains a public integer field `damage`. The goal is to instantiate this prefab at random positions within a specified area. Consider the following code snippet:
using System.Collections;
            using UnityEngine;
            
            public class EnemySpawner : MonoBehaviour {
                public GameObject enemyPrefab;
                public Vector3 areaSize;
                public int enemyCount;
            
                void Start() {
                    for (int i = 0; i < enemyCount; i++) {
                        InstantiateEnemy();
                    }
                }
            
                void InstantiateEnemy() {
                    Vector3 randomPosition = new Vector3(
                        Random.Range(-areaSize.x / 2, areaSize.x / 2),
                        0,
                        Random.Range(-areaSize.z / 2, areaSize.z / 2)
                    );
                    GameObject enemy = Instantiate(enemyPrefab, randomPosition, Quaternion.identity);
                    enemy.GetComponent<EnemyBehavior>().damage = Random.Range(10, 50);
                }
            }
Consider the above code snippet and choose the correct statement about how the prefabs will be instantiated and configured. 
            
            A: Enemies will spawn at fixed intervals 
            B: The enemies' y-coordinate will be random 
            C: Each enemy will most likely have a unique damage value 
            D: Prefabs will need to be set manually in the inspector 
            E: Quaternions are not used for rotation in instantiation

Medium

Synchronization and Latency
Synchronization
Latency
Client-Side Prediction
Solve
In a multiplayer Unity3D game using the UNet HLAPI, you want to implement a client-side prediction feature to reduce perceived latency. Consider the following pseudo code that represents a movement synchronization system between client and server:
struct PlayerState {
                Vector3 position;
                Quaternion rotation;
                float timestamp;
            }
            
            class Player : NetworkBehaviour {
                Queue<PlayerState> _stateBuffer;
                Vector3 _lastKnownPosition;
                Quaternion _lastKnownRotation;
                
                void Update() {
                    if (isLocalPlayer) {
                        CmdSendInputToServer(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
                    } else {
                        InterpolatePlayerState();
                    }
                }
            
                [Command]
                void CmdSendInputToServer(float h, float v) {
                    Vector3 movement = new Vector3(h, 0, v);
                    PlayerState state = new PlayerState {
                        position = transform.position + movement * Time.deltaTime,
                        rotation = transform.rotation,
                        timestamp = Time.time
                    };
                    RpcSyncStateWithClients(state);
                }
            
                [ClientRpc]
                void RpcSyncStateWithClients(PlayerState state) {
                    _stateBuffer.Enqueue(state);
                }
            
                void InterpolatePlayerState() {
                    // Detail on interpolation logic
                }
            }
Which of the following best describes the function and interaction of this synchronization mechanism in handling client prediction and latency?
A: The predictions occur server-side and all clients receive delayed updates leading to smooth rendering.
            B: Clients interpolate state using immediate server responses improving local movement fluidity.
            C: Server commands constrain client input ensuring prediction accuracy at the cost of responsiveness.
            D: Clients run prediction logic locally and periodically reconcile with server states to reduce perceived latency.
            E: Rotation synchronization suffices for latency compensation eliminating prediction necessity.
            F: State buffering on clients introduces latency in movement handling but helps in network event logging.
🧐 Question🔧 Skill

Medium

SO Application
ScriptableObjects
Data Management
Performance Optimization

2 mins

Unity
Solve

Medium

Prefab Instantiation
Prefabs
Instantiation
Scripting

2 mins

Unity
Solve

Medium

Synchronization and Latency
Synchronization
Latency
Client-Side Prediction

2 mins

Unity
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
SO Application
ScriptableObjects
Data Management
Performance Optimization
Unity
Medium2 mins
Solve
Prefab Instantiation
Prefabs
Instantiation
Scripting
Unity
Medium2 mins
Solve
Synchronization and Latency
Synchronization
Latency
Client-Side Prediction
Unity
Medium2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1200+ companies in 80+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️