Unity/게임 만들어보기 기록장
-
[Unity] Score 스크립트 만들기Unity/게임 만들어보기 기록장 2022. 10. 22. 19:09
1. UI - Canvas 클릭 2.스코어가 들어갈 Text클릭 3. 위치를 설정해준다 4.점수가 올라갈 영역을 만들어 준다 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public static int score = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { GetComponent().text = score.ToString(); } } ..
-
[Unity] Prefab을 이용하여 파이프 만들기Unity/게임 만들어보기 기록장 2022. 10. 22. 19:05
1. 파이프의 이미지를 놓아준다 2.새로운 폴더를 만들어서 폴더에 이미지 두개를 넣어준다 3. 파이프의 경계를 설정해준다 4. 만든 파이프를 이미지로 드래그 해준다. 5.파이프 이동시켜주기 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Move : MonoBehaviour { public float speed; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.position += Vector3.left * spe..
-
[Unity] 점프 기능 구현Unity/게임 만들어보기 기록장 2022. 10. 21. 18:59
using System.Collections; using System.Collections.Generic; using UnityEngine; public class BirdJump : MonoBehaviour { Rigidbody2D rb; public float jumpPower; // Start is called before the first frame update void Start() { rb = GetComponent(); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { rb.velocity = Vector2.up * jumpPower; //(0,3) } } 점프 파워조절