팁
- Ctrl+shift+B: 빌드셋팅
- Ctrl+shift+C: 콘솔창
- 에디터단계 / 런타임단계
- 메모리최적화에 콜라이더가 중요!
- Alpha는 위에있는 숫자
- Translate = 이동한다
- get은 우리가 가져오는거, set은 우리가 설정하는거!
- 스크립트에서 초록색은 어떤 명령들의 집합체
- fps : 60분의1초
- Update는 1프레임(fps)동안 실행함
변수 , 상수
- Int = 정수
- Float = 실수, 소수
- String = 문자열: “안녕” - 상수
- Bool = 참, 거짓 - 상수
변수의 3가지
- 선언
- 정의 // 초기화
- 사용
- This.gameobject.transform.translate(speed,0,0)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public int _moveSpeed; //변수 선언 과 동시에 초기화가 됨
int a;
float b;
string c;
bool d;
// Start is called before the first frame update
void Start()
{
a = 3;
b = 3.5f;
c = "안녕하세요";
d = true;
}
// Update is called once per frame
void Update()
{
//if (위 방향키를 누른다)
//{
// 이 스크립트(this)가 들어가 있는 게임오브젝트는 앞 방향으로 이동한다.
//}
// get은 우리가 가져오는거, set은 우리가 설정하는거!
// 초록색은 어떤 명령들의 집합체
if (Input.GetKey(KeyCode.UpArrow))
{
this.gameObject.transform.Translate(0, 0, _moveSpeed * Time.deltaTime); // 1초에 5만큼 움직인다
}
if (Input.GetKey(KeyCode.DownArrow))
{
this.gameObject.transform.Translate(0, 0, _moveSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
this.gameObject.transform.Translate(-_moveSpeed * Time.deltaTime, 0, 0);
}
if (Input.GetKey(KeyCode.RightArrow))
{
this.gameObject.transform.Translate(_moveSpeed * Time.deltaTime, 0, 0);
}
}
}
댓글남기기