일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
- rigidbody
- Ainimation Blending
- CSharp #자료구조
- Prefabs
- Object Pooling
- Animation State Machine
- 일시정지
- Scrooling
- Hp바
- Blend Type
- 2D슈팅게임
- rotation
- Transform
- Parallax
- Object Poling
- 오브젝트 풀링
- 스크롤링
- 패럴렉스
- 프리팹
- Hpbar
- 유니티
- 플레이어 방향전환
- Vector3
- apk
- Unity
- 플레이어 이동
- raycasting
- joystick
- raycast
- LayerMark
- Today
- Total
주녘공부일지
[ShootingGame] 2. 총알 발사 구현하기 본문
1. 프리팹 생성
총알 프리팹을 만들고 에셋에 Prefabs 폴더를 만들어서 프리팹들을 관리
- 충돌할 범위를 콜라이더로 설정하고 충돌감지를 위해 리지드바디2D 추가하고 물리 연산 타입을 Kinematic으로 처리할 것이기 때문에 Is Trigger 체크
+ Resources.Load()를 이용할 Prefabs이라면 Resources 폴더에 넣어야 함
https://godgjwnsgur7.tistory.com/7?category=986022
[Unity] Prefab이란?
프리팹(Prefab) : 게임 오브젝트 -> 재사용 가능한 에셋 씬에 올라온 오브젝트에 접근할 수 없는데, 이를 하기 위해서는 인스턴스화된 오브젝트를 게임매니저에게 가지게 하여 프리팹의 오브젝트
godgjwnsgur7.tistory.com
2. 발사체 제거 경계
- Tag를 활용해 BorderBullet을 만들고 OnTriggerEnter2D로 발사체가 BorderBullet Tag를 가진 오브젝트에 충돌할 시에 오브젝트를 삭제하는 로직 // Collider의 Is Trigger 체크
- BorderBullet Tag 추가
3. 발사체 생성, 발사체 파워 설정
- Reload() : 발사 딜레이를 설정하는 재장전 함수 // Update()문에서 실행
- Fire() : 맨 위의 if문 조건 완료 시 밑에 switch문 로직 실행되어 총알을 발사하고 발사 후엔 딜레이 시간 0으로 초기화 // Update()문에서 실행
+ Instantiate(GameObject original ,Vector3 position ,Quaternion rotation)
- Instantiate(생성할 오브젝트, 생성할 위치, 회전 값);
+ 회전 값(3번째 인자)에 Quaternion.identity 입력 시, 회전x
https://docs.unity3d.com/kr/530/ScriptReference/Object.Instantiate.html
Unity - 스크립팅 API: Object.Instantiate
This function makes a clone of an object in a similar way to the Duplicate command in the editor. If you are cloning a GameObject, or something attached to a GameObject, then you can also optionally specify its position and rotation. If you are cloning a C
docs.unity3d.com
+ AddForce(Vector3 force, ForceMode)
- AddForce(방향*힘 값, 힘의 종류 ForceMode)
- rigidbody에 힘을 가하여 이동시키는 로직
https://godgjwnsgur7.tistory.com/10
[Unity] ForceMode(ForceMode2D)의 종류
Force : 연속 - 현실적인 물리현상 Impulse : 연속 + 질량 무시 - 오브젝트의 질량에 관계없이 이동 Acceleration : 불연속 - 짧은 순간의 힘, 충돌, 폭발, 등에 사용 VelocityChange : 불연속 + 질량 무시 - 질량..
godgjwnsgur7.tistory.com
https://github.com/godgjwnsgur7/ShootingGame
GitHub - godgjwnsgur7/ShootingGame
Contribute to godgjwnsgur7/ShootingGame development by creating an account on GitHub.
github.com
강의 출처
https://www.youtube.com/watch?v=JUG0GnsJHQw&list=PLO-mt5Iu5TeYtWvM9eN-xnwRbyUAMWd3b&index=2
'GameEngine > Unity - Lecture' 카테고리의 다른 글
[ShootingGame] 6. 아이템과 필살기 구현하기 (0) | 2022.01.29 |
---|---|
[ShootingGame] 5. UI 간단하게 완성하기 (0) | 2022.01.28 |
[ShootingGame] 4. 적 전투와 피격 이벤트 만들기 (0) | 2022.01.28 |
[ShootingGame] 3. 적 비행기 만들기 (0) | 2022.01.27 |
[ShootingGame] 1. 플레이어 이동 구현 (0) | 2022.01.25 |