J's Study log

[Unity] GetComponent 본문

Computer Language/Unity

[Unity] GetComponent

정우섭 2019. 2. 23. 03:13

 There are two ways to call components in script.


 First way to call a value from component by using script. 

For example, 'Transform.position.z'

This means 'position of z in component Transform'.


The other way to call components you should make a new value(doesn't matter local or member) type of the component you want to call. And declare the value equal GetComponent<typeOfComponent>(). Now the value can be called in function to call the component.


By using both ways well, you can make what you want like this.





If the condition of the object's Rigidbody is like this





The result is...




'Computer Language > Unity' 카테고리의 다른 글

[Unity] Input Arrow Keys  (0) 2019.02.25
[Unity] Camera Work  (0) 2019.02.25
[Unity] Script  (0) 2019.02.23
[Unity] Physics Material  (0) 2019.02.21
[Unity] Component  (0) 2019.02.19
Comments