当前位置:网站首页>Unity games and related interview questions
Unity games and related interview questions
2022-04-23 03:23:00 【C # primary advanced】
1、 Bean eater : Control the movement of characters through the keyboard When the character meets the enemy , The enemy disappeared
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cdr : MonoBehaviour {
public GameObject sq;
public GameObject cube;
void Start () {
Instantiate(sq);
for (int i = 0; i < 15; i++)
{
float x = Random.Range(-4.5f, 4.5f);
float z = Random.Range(-4.5f, 4.5f);
Instantiate(cube, new Vector3(x, 0.15f, z), Quaternion.Euler(0, 0, 45));
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class q : MonoBehaviour {
float speed=3;
void Update()
{
Rigidbody r = GetComponent<Rigidbody>();
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 pos = new Vector3(h, 0, v);
r.velocity = pos * speed;
}
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("EN"))
{
Destroy(other.gameObject);
}
}
}
- Game begins 3 Seconds later , Different positions in the game scene (x:0--10 z:2--8) Random simultaneous cloning 3 A game object
void Start()
{
StartCoroutine(AA());
}
IEnumerator AA()//15.
{
while (true)
{
yield return new WaitForSeconds(3f);
for (int i = 0; i < 3; i++)
{
int x = Random.Range(0, 10);
int z = Random.Range(2, 8);
Instantiate(cube, new Vector3(x, 0, z), Quaternion.identity);
}
}
}
Interview questions
One : What is a collaborative program ?
Start another logical processing while the main thread is running , To assist in the execution of current procedures , Coroutines are much like multithreading , But not multithreading ,Unity In fact, after the end of each frame to detect yield Whether the conditions of .
Two :Unity3d The difference between Collider and trigger in ?
The collider is the carrier of the trigger , The trigger is just an attribute of the collider . When Is Trigger=false when , The collider triggers collisions based on the physics engine , Produce the effect of collision , You can call OnCollisionEnter/Stay/Exit function ; When Is Trigger=true when , Collider ignored by physics engine , No collision effect , You can call OnTriggerEnter/Stay/Exit function . If you want to detect the contact of an object and don't want collision detection to affect the movement of an object or whether an object passes through an area in space, you can use a trigger
3、 ... and : The necessary conditions for an object to collide ?
Both objects must have colliders (Collider), One of the objects must also have Rigidbody rigid body , And it must be a moving object with Rigidbody Script can detect collision .
Four :CharacterController and Rigidbody The difference between
Rigidbody With completely real physical properties ,Unity The most basic component of a physical system in , Contains common physical properties , and CharacterController It can be said to be limited Rigidbody, It has a certain physical effect, but it is not completely real , yes Unity A component encapsulated to enable developers to easily develop games from the first person perspective
5、 ... and : sketch prefab Usefulness ( Presupposition )
Instantiate when the game is running ,prefab It's like a template , For the material you already have 、 Script 、 Parameter to make a default configuration , For future modification , meanwhile prefab The packaged content simplifies the export operation , Facilitate team communication .
6、 ... and : In the whole process of object collision , There are several stages , List the corresponding functions respectively
Three stages ,1.OnCollisionEnter 2.OnCollisionStay 3.OnCollisionExit
7、 ... and :Unity3d In our physics engine , There are several ways to apply force , Describe them separately
rigidbody.AddForce/AddForceAtPosition, All in rigidbody In a series of functions . You can check it yourself rigidbody Of API
8、 ... and :Unity3d Scripts have a relatively complete life cycle from wake-up to destruction , Please list some important methods of the system .
Awake——>OnEnable–>Start——>Update——>FixedUpdate——>LateUpdate——>OnGUI——>OnDisable——>OnDestroy
版权声明
本文为[C # primary advanced]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621093423.html
边栏推荐
- General testing technology [1] classification of testing
- Peut recevoir plusieurs paramètres de type de données - paramètres variables
- Student achievement management
- Top 9 task management system in 2022
- Do you really understand hashcode and equals???
- Optimization of especially slow startup in idea debugging mode
- [untitled]
- Visual programming - Experiment 1
- Charles uses three ways to modify requests and responses
- 场景题:A系统如何使用B系统的页面
猜你喜欢
【VS Code】解决jupyter文件在vs code中显示异常的问题
"Visual programming" test paper
可以接收多種數據類型參數——可變參數
Top 9 task management system in 2022
Visual programming -- how to customize the mouse cursor
《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
全新的ORM框架——BeetlSQL介绍
关于idea调试模式下启动特别慢的优化
12. < tag linked list and common test site synthesis > - lt.234 palindrome linked list
. net webapi access authorization mechanism and process design (header token + redis)
随机推荐
批量下载文件----压缩后再下载
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
可以接收多种数据类型参数——可变参数
集合之List接口
[untitled]
Advanced sorting - fast sorting
2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
Five tips for cross-border e-commerce in 2022
Comprehensive calculation of employee information
2022t elevator repair test simulation 100 questions and online simulation test
C abstract class
关于idea调试模式下启动特别慢的优化
. NETCORE sets the API post mode, which can accept parameters directly in parentheses
Flink实时数仓项目—DWS层设计与实现
Experiment 5 components and event handling
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
Why is bi so important to enterprises?
Iotos IOT middle platform is connected to the access control system of isecure center
Xutils3 corrected a bug I reported. Happy
POI create and export Excel based on data