当前位置:网站首页>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
边栏推荐
- 3dsmax2018 common operations and some shortcut keys of editable polygons
- #775 Div.1 C. Tyler and Strings 组合数学
- Stage experience
- windows下Redis-cluster集群搭建
- 2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
- Flutter tips: various fancy nesting of listview and pageview
- Download the details and sequence of the original data access from the ENA database in EBI
- 2020-10-27
- 775 Div.1 C. Tyler and strings combinatorial mathematics
- mysql审计日志归档
猜你喜欢

LeetCode之单词搜索(回溯法求解)

3dsmax snaps to frozen objects

AutoCAD - workspace settings

AutoCAD - window zoom

计组笔记(1)——校验码、原补码乘除计算、浮点数计算

XSS injection

Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
![Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]](/img/e7/f699ee982ea325b8d04f8bd467a559.jpg)
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
![[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)](/img/03/329adb314606f29c8a4cb2260e84c8.jpg)
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
![[groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)](/img/aa/3c8b7b27e322417777d1315b9a5a8f.jpg)
[groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)
随机推荐
Create a pyGame window with a blue background
Inline built-in function
次小生成树
mysql审计日志归档
How to choose a panoramic camera that suits you?
A survey of automatic speech recognition (ASR) research
AutoCAD - graphic input and output
Error statuslogger log4j2 could not find a logging implementation
Variable category (automatic, static, register, external)
【acwing】240. food chain
AutoCAD - window zoom
Interface joint commissioning test script optimization V5.0 (end)
MD5绕过
Solutions and answers for the 2021 Shenzhen cup
Flink集群配置
AutoCAD - Zoom previous
[crampon programming] lintcode decoding Encyclopedia - 872 termination process
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
AutoCAD - full screen display
China polyurethane rigid foam Market Research and investment forecast report (2022 Edition)