Material = ์
ฐ์ด๋ + ํ
์ค์ณ
, ์ค๋ธ์ ํธ์ ํฝ์
์ปฌ๋ฌ๋ฅผ ๊ฒฐ์ ํ๋ค.
์
ฐ์ด๋ - ์ฃผ์ด์ง ์
๋ ฅ์ ๋ฐ๋ผ ํฝ์
์ ์ต์ข
์ปฌ๋ฌ๋ฅผ ๊ฒฐ์
ํ
์ค์ฒ - ํ๋ฉด์ ์
ํ๋ ์ด๋ฏธ์งํ์ผ
์๋ฒ ๋(Albedo) - ๋ฐ์ฌ์จ, ๋ฌผ์ฒด ํ๋ฉด์ ๊ธฐ๋ณธ์
ํ์ ์
์ฅ์์ ์ถฉ๋ํ ๊ฒ์ ์ค๋ธ์ ํธ๊ฐ ํ๋ ์ด์ด์ธ์ง ๊ตฌ๋ถํ๋ค.
์ ๋ ฅ์ ๊ฐ์งํ๋ ๊ธฐ๋ฅ - Update(), Inputํด๋์ค์ ์ ๋ ฅ ๊ฐ์ง ๋ฉ์๋
ํ ํ๋ ์์ ํ๋ฒ, ๋งค ํ๋ ์๋ง๋ค ๋ฐ๋ณต ์คํ
Input ํด๋์ค - ์ฌ์ฉ์ ์
๋ ฅ์ ๊ฐ์งํ๋ ๋ฉ์๋๋ฅผ ๋ชจ์๋ ์งํฉ
if(Input.GetKey(Keycode.Uparrow) == true){
playerRigidbody.Addforce(0f, 0f, speed)
Input.GetKey()
- ํค๋ณด๋์ ์๋ณ์๋ฅผ KeyCodeํ์
์ผ๋ก ์
๋ ฅ๋ฐ์
gameObject.SetActive(false)
// ์์ ์ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๋นํ์ฑํ
gameObject
| ์ปดํฌ๋ํธ ์
์ฅ์์ ์์ ์ด ์ถ๊ฐ๋ ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๊ฐ๋ฆฌํค๋ GameObjectํ์
์ ๋ณ์
SetActive()
| ์ค์ค๋ก ๊ฒ์ ์ค๋ธ์ ํธ๋ฅผ ๋๊ณ ์ผ๋ ๊ธฐ๋ฅ์ ์ฝ๋์์ผ๋ก ๊ตฌํ
private Rigidbody playerRigidbody;
playerRigidbody = GetComponent<Rigidbody>();
์ ๋ค๋ฆญ
| <>, ์ ๋ค๋ฆญ์ ๋ฉ์๋๋ ํด๋์ค๊ฐ ์ฌ๋ฌ ํ์
์ ํธํ๋๊ฒ ํ๋ค.
void Update()
{
// ์ํ์ถ๊ณผ ์์ง์ถ์ ์
๋ ฅ๊ฐ์ ๊ฐ์งํ์ฌ ์ ์ฅ
float xInput = Input.GetAxis("Horizontal");
float zInput = Input.GetAxis("Vertical");
// ์ค์ ์ด๋ ์๋๋ฅผ ์
๋ ฅ๊ฐ๊ณผ ์ด๋ ์๋ ฅ์ ์ฌ์ฉํด ๊ฒฐ์
float xSpeed = xInput * speed;
float zSpeed = zInput * speed;
// Vector3 ์๋๋ฅผ (xPeed, 0, zSpeed)๋ก ์์ฑ
Vector3 newVelocity = new Vector3(xSpeed, 0f, zSpeed);
// ๋ฆฌ์ง๋๋ฐ๋์ ์๋์ newVelocity ํ ๋น
playerRigidbody.velocity = newVelocity;
}
GetAxis()
| ์ด๋ค ์ถ์ ๋ํ ์
๋ ฅ๊ฐ์ ์ซ์๋ก ๋ฐํํ๋ ๋ฉ์๋
ex ) Horizontal, Vertical etc..
Vector3
| ์์ x, y, z๋ฅผ ๊ฐ์ง๋ ํ์
๐ผ AddForce()์ velocity์ ์ฐจ์ด
๊ด์ฑ ์ฐจ์ด
AddForce() ๋ฉ์๋์์๋ ํ์ ๋์ ํ๊ณ ์๋ ฅ์ ์ ์ง์ ์ผ๋ก ์ฆ๊ฐ์ํจ๋ค.
Rigidbody์ velocity๋ฅผ ์์ ํ๋ ๊ฒ์ ์ด์ ์๋๋ฅผ ์ง์ฐ๊ณ ์๋ก์ด ์๋๋ฅผ ์ฌ์ฉ ํ๋ ๊ฒ์ด๋ค. ๋ฐ๋ผ์ ๊ด์ฑ์ ๋ฌด์ํ๊ณ ์๋๊ฐ ์ฆ์ ๋ณ๊ฒฝ๋๋ค.\
// ์ํ์ถ๊ณผ ์์ง์ถ์ ์
๋ ฅ๊ฐ์ ๊ฐ์งํ์ฌ ์ ์ฅ
float xInput = Input.GetAxis("Horizontal");
float zInput = Input.GetAxis("Vertical");
์ฝ๋ (์ค์ ๋ฐ์ฌ ๊ธฐ๋ฅ) <-> ์
๋ ฅ ์ด๋ฆ("๋ฐ์ฌ") <-> ์
๋ ฅ ์ฅ์น(๋ง์ฐ์ค ์ผ์กฑ ๋ฒํผ)
์ฝ๋ (์ค์ ๋ฐ์ฌ ๊ธฐ๋ฅ) <-> ์
๋ ฅ ์ด๋ฆ("๋ฐ์ฌ") <-> ์
๋ ฅ ์ฅ์น(๋ง์ฐ์ค ์ค๋ฅธ์ชฝ ๋ฒํผ)
์ถ = ์
๋ ฅ ์ด๋ฆ
๋๋ฒ์งธ Horizontal ์ถ๊ณผ Vertical ์ถ : ์์ค๋ฐ์ค์ ๊ฐ์ ์ฝ์ ๊ฒ์๊ธฐ ๊ฒ์ ํจ๋์ ์กฐ์ด์คํฑ์ ๋์๋๋ค.