전체 글(164)
-
0409 총알 피하기 게임 (랜덤 총알 + 유도탄 생성)
매터리얼 - 쉐이더와 텍스쳐가 합쳐진 에셋 -오브젝트의 픽셀 컬러를 결정 쉐이더 -주어진 입력에 따라 픽셀의 최종 컬러를 결정하는 코드 -질감과 빛에 의한 반사광과 빛의 굴절을 만듦 Input.GetKeyDown Input.GetKeyUp Input.GetKey: 키를 누르고 있는 동안 값 받기 AddForce: 관성이 적용되고, 가속이 된다. using UnityEngine; public class BulletSpawner : MonoBehaviour { public GameObject bulletPrefab; //생성할 탄알의 원본 프리팹 public float spawnRateMin = 0.5f; //최소 생성주기 public float spawnRateMax = 3f; private Transfo..
2021.04.09 -
0408 마우스 클릭하는 곳으로 캐릭터 이동시키기
using UnityEngine; public class Hero : MonoBehaviour { public GameObject model; public float moveSpeed = 2f; private Vector3 targetPosition; private bool isMove; private Animation anim; public void Init() { //초기화 this.anim = this.model.GetComponent(); } private void Update() { if (this.isMove) { //이동 //방향*속도*시간(Time.deltaTime) this.transform.Translate(0, 0, moveSpeed * Time.deltaTime); var dista..
2021.04.08 -
0408 타겟 포인트로 달려가서 적 때리기
using UnityEngine; using UnityEngine.UI; public class UIGame : MonoBehaviour { public Button btnAttack; public Button btnRun; public Text Hp; private void Start() { } private void Update() { this.Hp.GetComponent().text = this.Hp.ToString(); } } using UnityEngine; public class InGame : MonoBehaviour { public Transform TargetPoint; public UIGame uiGame; public CharacterController player; public Ch..
2021.04.08 -
0407 점수 쌓이는 ui, 랜덤 발생 오브젝트, 클릭하는 곳으로 이동
raycast 쏘는 법 추가 using UnityEngine; public class ItemController : MonoBehaviour { public float dropSpeed = 0; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { this.transform.Translate(0, -0.03f, 0); if (this.transform.position.y < -1.0f) { Destroy(gameObject); } } } using UnityEngine; public class BasketController : MonoBehaviou..
2021.04.08 -
0407 3d 밤송이 던지기
using UnityEngine; public class BamsongiGenerator : MonoBehaviour { public GameObject bamsongiPrefeb; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { //프리팹으로 가지고 게임 오브젝트 생성 var go = Instantiate(bamsongiPrefeb); var ray = Camera.main.ScreenPointToRay(Input.mousePosition); Debug.DrawRay(ray.orig..
2021.04.07 -
0407 애니메이션 구현하기
using UnityEngine; public class PlayerController : MonoBehaviour { Rigidbody2D rigid2D; Animator animator; float jumpForce = 340.0f; float walkForce = 50.0f; float maxWalkSpeed = 2.0f; // Start is called before the first frame update void Start() { this.rigid2D = GetComponent(); this.animator = GetComponent(); } // Update is called once per frame void Update() { //점프한다. if (Input.GetKeyDown(KeyC..
2021.04.07