-
[ TIL 220922 ] THUToday I Learned 2022. 9. 24. 03:06
๐ Unity ๋ ํธ๋ก์ ์ ๋ํฐ ๊ฒ์ํ๋ก๊ทธ๋๋ฐ ์์ผ์ค
- Frame : ๋งค๋ฒ ์๋ก ๊ทธ๋ฆฌ๋ ๊ฐ๊ฐ์ ํ๋ฉด
- FPS ( Frame Per Second ) : 1์ด๋์ ํ๋ฉด์ด ์๋ก ๊ทธ๋ ค์ง๋ ํ์ = ์ด๋น ํ๋ ์using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { Rigidbody playerRigidbody; // ์ด๋์ ์ฌ์ฉํ ๋ฆฌ์ง๋๋ฐ๋ ์ปดํฌ๋ํธ float speed =8f; //์ด๋์๋ ฅ void Start() { playerRigidbody=GetComponent<Rigidbody>(); //rigidbody ์ปดํฌ๋ํธ ๊ฐ์ ธ์ค๋ ํจ์ // ์์ ๋ณ์๋ค public ์์ ๊ณ , ์ด๋ ๊ฒ ํ๋ ๋ฐฉ์์ด ๋ ๋ฐ๋์งํจ //์ถ๊ณํ์? ์ถ๋ฐฉํฅ์ผ๋ก ํ๋ ๊ฑธ ๋ง์ด ์ฌ์ฉ } void Update() { float xInput= Input.GetAxis("Horizontal"); float yInput = Input.GetAxis("Vertical"); //axis๋ ์ถํ ์ค๋ช float xSpeed = xInput*speed; float ySpeed = yInput*speed; Vector3 newVelocity = new Vector3(xSpeed, 0, ySpeed); playerRigidbody.velocity= newVelocity; //๋ฑ์ ์ด๋ vector3ํ์ ์ผ๋ก ๋ฃ์ด์ฃผ๋ฉด ๋จ // if(Input.GetKey(KeyCode.UpArrow)){ // //์์ชฝ ๋ฐฉํฅํค ์ ๋ ฅ์ด ๊ฐ์ง๋ ๊ฒฝ์ฐ z ๋ฐฉํฅ ํ ์ฃผ๊ธฐ // playerRigidbody.AddForce(0f,0f,speed); //์๋ฐฉํฅ์ z๋ฐฉํฅ // ์ปจํธ๋กคํ๊ธฐ ์ด๋ ค์. ๋ฑ์ํ๋ฉด ์ข์๋ฏ // } // if(Input.GetKey(KeyCode.DownArrow)){ // playerRigidbody.AddForce(0f,0f,-speed); // } // if(Input.GetKey(KeyCode.RightArrow)){ // playerRigidbody.AddForce(speed,0f,0f); // } // if(Input.GetKey(KeyCode.LeftArrow)){ // playerRigidbody.AddForce(-speed,0f,0f); // } } public void Die(){ //์์ ์ ๊ฒ์ ์ค๋ธ์ ํธ(๊ฐ์ฒด)๋ฅผ ๋นํ์ฑํ gameObject.SetActive(false); // public ์์ ๋ฉด ์๋์ผ๋ก private ์ผ๋ก ? } }
'Today I Learned' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ TIL - 220928 ] (0) 2022.09.29 [ TIL 220927 ] (0) 2022.09.28 [ TIL 220921 ] (1) 2022.09.22 [ TIL 220920 ] (1) 2022.09.21 [ TIL : 220913 ] (0) 2022.09.21