Explain Prefabs.
Prefabs can be dragged and dropped from the hirachy to assests to always instanciate mulitples.
Explain Collision Matrix.
is responsable for defined interactions between layers.
Explain raycast and its parameters (Raycast(…)).
is a ray with a cetain lengh, direction and lets you know if you hit smth.
Raycast(origin, target, length, Layermask)
Why should Vectors be normalized in unity3d?
normalizing vectors in Unity3D ensures consistent scales, simplifies comparisons and calculations, improves performance, and helps avoid division by zero issues.
Explain fixedtimestamp. Why does it affect gamespeed?
We use time.deltatime because frames can very.
In what order are the Unity event functions?
Awake()
OnEnable()
Start()
Update()
fixedUpdate()
lateUpdate()
OnGui()
OnApplicationQuit()
OnApplicationPause()
OnDisable()
OnDestroy()
What does the code look like of an object that is moving towards a target and stops at 1.0?
Vector3 target;
float speed;
void update(){
float distance = Vector3.distance(target, transform.position)
if(distance>1.0f){
Vector3.direction=target - transform.position;
direction.Normalize();
transform.position += direction*speed*Time.deltatime;
}
What are the differences between Update(), fixedUpdate() and lateUpdate() in Unity?
Update(): Called once per frame, it is used for general updates and input handling.
FixedUpdate(): Called at a fixed interval, it is used for physics-related calculations and updates to ensure consistent results across different frame rates.
LateUpdate(): Called after all Update() functions, it is used for camera-related operations and smooth object tracking, ensuring objects have finished their regular updates before applying camera adjustments.
Whats the difference between Start() and Awake()?
Start(): Called before the first frame update, it is used for initializing variables and setting up references between objects.
Awake(): Called when a script instance is loaded, it is used for early initialization, such as setting up references between scripts or performing tasks that need to happen before the game starts.
What is the difference between a static class and a sigleton class?
Static Class: A static class cannot be instantiated and is accessed directly through the class itself. It is commonly used to hold utility methods or constants that can be accessed from anywhere in the program without needing an instance of the class.
Singleton Class: A singleton class allows only one instance of the class to be created and provides a global point of access to that instance. It is typically used when you want to ensure there is only one instance of a particular class throughout the application, such as a manager or controller class.
What does the yield keyword do?
In Unity, the yield keyword is primarily used within coroutine functions to introduce delays or wait for certain conditions. It allows for the execution of time-based or asynchronous operations without blocking the main thread, thereby preventing the game from freezing or becoming unresponsive.
yield
What is a coroutine function in Unity?
A coroutine function in Unity allows for the execution of time-based or asynchronous operations in a controlled manner, pausing and resuming the function's execution over multiple frames.
Explain asynchronous operations in unity.
In Unity, an asynchronous operation refers to a task that can run independently from the main thread, allowing other operations to continue without blocking or freezing the game.
Name examples for asynchronous operations in unity.
Loading and streaming large assets or levels in the background.
Making network requests or communicating with web services.
Performing database operations or file I/O.
Processing complex calculations or simulations.
Explain invoke methods.
In Unity, the Invoke methods are used to schedule the execution of a method or function after a specified delay. They provide a simple way to execute code after a certain time has elapsed.
Invoke
The Invoke methods allow you to call a method by providing its name as a string parameter or by using a delegate or lambda expression. You can specify the delay in seconds before the method is invoked.
These methods are commonly used for time-based events, such as triggering animations, spawning objects, or executing actions after a specific delay.
In summary, the Invoke methods in Unity provide a convenient way to schedule the execution of methods or functions after a delay, allowing for time-based events and actions in your game or application.
What are the differences between invoke and coroutine?
The differences between Invoke and coroutines in Unity are:
Invoke is a simple way to schedule the execution of a method or function after a specified delay. It is straightforward to use but limited in functionality.
Coroutines offer more flexibility and control over time-based operations. They allow for complex, asynchronous behavior and can be paused, resumed, and executed over multiple frames. Coroutines are defined using special functions with the yield keyword.
In summary, Invoke is a basic mechanism for scheduling simple delayed method calls, while coroutines provide more advanced features and control for handling time-based operations in Unity.
Explain delegates and why we use them.
Delegates in Unity are a type of reference to a method, allowing you to pass and invoke functions dynamically. They provide a way to decouple code and enable flexible event-driven programming.
Delegates are commonly used in Unity for event handling, callbacks, and creating modular and extensible systems. They allow you to define and pass around functions as parameters, making it possible to react to events or trigger actions without knowing the exact implementation details.
By using delegates, you can achieve loose coupling between different components and scripts, making your code more modular, reusable, and maintainable. Delegates also facilitate the implementation of the observer pattern, where multiple objects can subscribe to and be notified of specific events or changes.
In summary, delegates in Unity provide a mechanism for dynamic method references, enabling event handling, callbacks, and flexible, decoupled programming patterns.
What is 2.5D in Unity?
2D physics with 3D graphics.
What is the difference between 2D and 3D in Unity?
No actual difference. Unity is a 3D engine. 2D are just sprites, wich are textures on a flat mesh. In 2D rotation of the camera is locked.
Explain WorldSpace, LocalSpace and ScreenSpace.
WS: GameObjects are in the WorldSpace.
LS: any children of the GameObject.
SS: everything on the canvas (UI)
In summary, WorldSpace represents positions in the global scene, LocalSpace represents positions relative to an object's own local origin and parent-child relationships, while ScreenSpace is a coordinate system based on the screen or viewport for UI and screen-related calculations.
Name a few steps to optimize gameperformance.
Profiling (to analyze the problem)
Batching
reduce texture size
occlusion culling
reduce the number of gameObjects
Object pooling (bullet+gun)
How can we load two scenes at once in hirachy scene?
With async. scenemanager.loadscene; (loadasynchscene instead)
What does Monobehaviour mean?
its the basic class from wich every Unity script derives. So you can use Awake, Start, Update (all predefined methods).
Name two ways to change a texture during runtime.
Texture2D;
tex = Resources.Load(“myPicture”) as Texture2D;
obj.render.material.mainTexture = tex;
Create a material an directly pass to the render material in the view.
Explain Quaterion.
Quaterion are used to represent roations.
Quaternion in Unity is a mathematical representation of rotations. It is a four-dimensional vector that represents the orientation of an object in three-dimensional space. Quaternions are used to smoothly interpolate between rotations and avoid the issues of gimbal lock.
Explain Mesh in Unity.
In Unity, a mesh is a collection of vertices, edges, and faces that define the shape and geometry of a 3D object. It is the fundamental component used to render and display 3D models in the game world. A mesh consists of vertex positions, normals, UV coordinates, and other optional attributes that determine its appearance and behavior.
Explain Kinematic Rigidboy in Unity.
Unity will not apply any physics to that object.
In Unity, a kinematic Rigidbody is a type of physics component that allows an object to be controlled by animations or script-driven transformations while still interacting with other physics objects. It does not respond to forces or collisions from the physics engine, but can move and rotate manually.
Explain scriptable Objects.
In Unity, Scriptable Objects are assets that allow you to create custom data containers or behavior templates that can be reused and shared across multiple instances.
Explain the new inputSystem.
The new input system in Unity 3D is a unified and highly customizable system for handling player input. It offers improved performance, cross-platform support, and a more intuitive and flexible approach to input handling. The new input system provides features such as action-based input mapping, input device management, and input-driven events, allowing for easier implementation of complex input interactions in games and applications.
Name the differences between material & physics materials in unity.
Material: a file that contains information about the lighting of an Object.
Physics Material: is used to adjust friction and bouncing effets of colliding objects.
Explain textures.
Images or Movies that lay over a wrap around your object to give them a visual effect (3D=texture, 2D=sprite).
What is a render texture?
In Unity, a Render Texture is a special type of texture that allows rendering and storing the result of a camera or a specific portion of the scene to be used as a texture. It can be used for various purposes, including creating mirrors, surveillance cameras, dynamic reflections, or post-processing effects.
What is a culling mask?
Each camera can be set to only display a subset of the available layers. This is handy for placing 3D Objects in on layer visible. by the main camera, and say the GUI in another layer visible by a different camera.
Name the difference between projection perspective and orthographic.
In summary, perspective projection provides depth and realistic scaling based on object distance, while orthographic projection maintains consistent object sizes regardless of distance, resulting in a more flat and uniform appearance.
What is a profiler?
You can get information about the performance of the application.
What is the NavMesh system? What kind of Mesh are there?
By using the NavMesh system, developers can easily implement navigation and movement for NPCs (Non-Player Characters), AI-controlled enemies, or any other character that requires autonomous movement in the game world.
NavMesh: where you can go and where not.
NavMeshAgent: controls character navigation on the NavMesh.
Off-Mesh Links: enable special connections between disconnected areas.
NavMeshObstacle: allows for dynamic obstruction of the NavMesh to influence pathfinding and movement.
What is the use of Joints?
Joints in Unity are used to create and simulate physical connections between rigid bodies. They allow for the creation of complex and realistic interactions between objects in a physics-based environment.
What kind of Joints are there? Explain each one.
Hinge Joint: Restricts rotation around a single axis, similar to a door hinge. It allows the connected objects to swing or rotate like a door.
Fixed Joint: Completely locks the position and rotation of two objects together. They behave as if they are a single rigid body and do not allow any movement or rotation relative to each other.
Spring Joint: Simulates a spring-like behavior between two objects, allowing them to stretch or compress. It can be used to create elastic connections or simulate realistic spring physics.
Character Joint: Designed for character movement, it simulates joints similar to human joints. It provides control over rotation and limits on movement, allowing for more natural and realistic character animations.
Configurable Joint: Offers a wide range of customization options for creating complex joint behaviors. It allows you to specify parameters like limits, rotations, and motion along multiple axes, providing more flexibility in creating unique joint configurations.
Distance Joint: Constrains two objects to a specific distance from each other. It can be used to simulate chains, ropes, or other flexible connections.
Slider Joint: Restricts movement along a single axis, allowing objects to slide back and forth. It is commonly used for creating sliding doors, drawers, or other linear movements.
Explain Model Class.
In Unity, a model class represents and manages data for a specific game object or concept, providing properties and methods to define its characteristics and behavior (JSON Files e.g.).
Explain JSON.
Java Script Object Notation.
Easy for humans and machines to read and write. Its a text format that is completely language idependent and therefore an ideal data interchange language.
What is a SerialzedField?
In Unity, the [SerializeField] attribute is used to expose private variables in the Unity Inspector. It allows the variable to be serialized, meaning its value can be saved and restored when the Unity project is saved or the scene is loaded. This attribute is commonly used when you want to expose certain variables for editing in the Inspector while keeping them private or hidden from other scripts.
What is a serialzeable? And what do we use it for?
n Unity, the [Serializable] attribute is used to make a class or struct capable of being saved and transferred in a serialized format. It allows objects of that type to be converted into a format that can be stored or transmitted, enabling easy saving, loading, and sharing within Unity.
We can use it e.g. for saving and Loading: By marking classes or structs as serializable, you can save and load their instances to and from disk or other storage mediums. This is useful for preserving game progress, storing user preferences, or creating custom file formats.
Last changed2 years ago