当前位置:网站首页>Unity synergy
Unity synergy
2022-07-05 04:52:00 【yaohuiyaoo】
One . Operation of game object
1. Find game objects
1.1 Find by name :
GameObject cube1=GameObject.Find(“ Game object name ”);
1.2. Find... According to the label :
GameObject cube2=GameObject.Find(“ Tag name ”);
It is more efficient to find according to the label , Search faster
2. Get components
2.1 Format : Component type g=this.GetComponent< Component type >();
Be careful : If it is to obtain the component of the current game object , The current game object does not have this component , You cannot succeed
2.2 After getting the component, you can modify the value in the component .
3. Add the component
3.1 Get rigid body format : gameobject.AddComponent();
3.2 You can not only add components , You can also add scripts , Preset body, etc
4.Random
float a=Random.value; // return 0.0( Include ) To 1.0( Include ) Number between
int b=Random.Range(0,100); // Including the minimum but excluding the maximum
float c=Random.Range(0.0f,5.5f); // Including maximum and minimum
5. clone
5.1 Format :Instantiate( Presupposition , coordinate , Rotation Angle )
5.2 Randomly clone objects on the map :
Instantiate(cube,new Vector(Random.Range(0,100),Random.Range(0,100),Random.Range(0,100)),Quaternion.identity) //Quaternion.identity Indicates no rotation
6. Destroy game objects
Destory( The game object );
Destory( The game object ,3f); //3 Destroy in seconds
2. Keyboard events
Input.GetKey( Specific keys of the keyboard ) // Press this key to lift every frame that does not press this key
Input.GetKeyDown( Specific keys ) // Press to call once
Input.GetKeyUp( Specific keys ) // Lift it up and call it once without pressing the key
Use keys to control the movement of objects
float h=Input.GetAxis(“Horizontal”)Time.deltaTimespeed;// Move up and down
float v=Input.GetAxis(“Vertical”)Time.deltaTimespeed;// Or so mobile
transform.Translatr(new Vector(h,0,v));
3、 ... and . coroutines
A coroutine is something that makes a program run the main program , Run the process at the same time , And update similar , Has been running
No direct update() It calls the coroutine
边栏推荐
- Manually implement heap sorting -838 Heap sort
- 次小生成树
- [crampon programming] lintcode decoding Encyclopedia - 1100 strange printer
- Function template
- 2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem
- A survey of automatic speech recognition (ASR) research
- 2022-2028 global and Chinese equipment as a Service Market Research Report
- 介绍汉明距离及计算示例
- windows下Redis-cluster集群搭建
- On-off and on-off of quality system construction
猜你喜欢
Introduction to JVM principle and process
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
【Leetcode】1352. 最后 K 个数的乘积
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)
On-off and on-off of quality system construction
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
【acwing】240. food chain
AutoCAD - set layer
Wenet: E2E speech recognition tool for industrial implementation
随机推荐
Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation
3dsmax common commands
2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
Forecast report on research and investment prospects of Chinese wormwood industry (2022 Edition)
Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?
Leetcode 222 number of nodes of complete binary tree
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
[crampon programming] lintcode decoding Encyclopedia - 872 termination process
669. 修剪二叉搜索树 ●●
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
Is $20billion a little less? Cisco is interested in Splunk?
A survey of automatic speech recognition (ASR) research
中国金刚烷行业研究与投资预测报告(2022版)
AutoCAD - stretching
China polyurethane rigid foam Market Research and investment forecast report (2022 Edition)
49 pictures and 26 questions explain in detail what is WiFi?
2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
2020-10-27
中国针状焦行业发展研究与投资价值报告(2022版)