当前位置:网站首页>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 test technology [II] test method
- Comprehensive calculation of employee information
- socket編程 send()與 recv()函數詳解
- Peut recevoir plusieurs paramètres de type de données - paramètres variables
- Generate QR code through zxing
- Charles uses three ways to modify requests and responses
- 移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
- 2022 P cylinder filling training test questions and simulation test
- 2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
- Oracle query foreign keys contain comma separated data
猜你喜欢

2022a special equipment related management (elevator) work license question bank and simulation examination

超好用的【通用Excel导入功能】

关于idea调试模式下启动特别慢的优化

二进制文件版本控制工具选择难?看完这篇你会找到答案

Chapter 8 of C language programming (fifth edition of Tan Haoqiang) is good at using pointer exercises to analyze and answer

可以接收多种数据类型参数——可变参数

Visual programming - Experiment 1
![Eight elder brothers chronicle [4]](/img/87/f695d0275f8a66b9def48a75668d15.png)
Eight elder brothers chronicle [4]

It can receive multiple data type parameters - variable parameters

MySQL之explain关键字详解
随机推荐
Experiment 5 components and event handling
The query type of MySQL is very inefficient.
Fiddler use
Idempotency practice operation, explaining idempotency based on business
为什么BI对企业这么重要?
Do you really understand hashcode and equals???
C-11 problem h: treasure chest 2
Generate QR code through zxing
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
[MySQL] left Function | Right Function
Iotos IOT middle platform is connected to the access control system of isecure center
WinForm allows the form form to switch between the front and active states
MySQL之explain关键字详解
Configure automatic implementation of curd projects
Problem C: realize Joseph Ring with linked list
Explanation keyword of MySQL
Super easy to use [general excel import function]
C abstract class
第四次作业
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination