当前位置:网站首页>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
边栏推荐
- Preview of converting doc and PDF to SWF file
- 2022g2 boiler stoker examination question bank and online simulation examination
- Flink customizes the application of sink side sinkfunction
- Eight elder brothers chronicle [4]
- Can you answer the questions that cannot be answered with a monthly salary of 10k-20k?
- Is it difficult to choose binary version control tools? After reading this article, you will find the answer
- Iotos IOT middle platform is connected to the access control system of isecure center
- 批量下載文件----壓縮後再下載
- Visual programming - Experiment 2
- Explication détaillée des fonctions send () et recv () du programme Socket
猜你喜欢

Iotos IOT middle platform is connected to the access control system of isecure center

移植tslib时ts_setup: No such file or directory、ts_open: No such file or director

《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案

12.<tag-链表和常考点综合>-lt.234-回文链表

QT dynamic translation of Chinese and English languages

Why is bi so important to enterprises?

Xutils3 corrected a bug I reported. Happy

2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination

一套组合拳,打造一款 IDEA 护眼方案

Flink customizes the application of sink side sinkfunction
随机推荐
可以接收多种数据类型参数——可变参数
JS implementation of new
General testing technology [1] classification of testing
[MySQL] left Function | Right Function
打卡:4.22 C语言篇 -(1)初识C语言 - (11)指针
幂等性实践操作,基于业务讲解幂等性
. net webapi access authorization mechanism and process design (header token + redis)
Top ten project management software similar to JIRA
可以接收多種數據類型參數——可變參數
2022g2 boiler stoker examination question bank and online simulation examination
Generate QR code through zxing
关于idea调试模式下启动特别慢的优化
MySQL索引详解【B+Tree索引、哈希索引、全文索引、覆盖索引】
“如何实现集中管理、灵活高效的CI/CD”在线研讨会精彩内容分享
After the mobile phone is connected to the computer, how can QT's QDIR read the mobile phone file path
2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
集合之List接口
2022 P cylinder filling training test questions and simulation test
Five tips for cross-border e-commerce in 2022
Supersocket is Use in net5 - startup