본문 바로가기
728x90

Unity32

[Unity3D] Coroutine 활용 예제 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Masaki : MonoBehaviour { Coroutine routine; Animator anim; Rigidbody rbody; Vector3 dir; Vector3 hitPoint; public float walkSpeed = 1.0f; void Start() { anim = this.GetComponent(); rbody = this.GetComponent(); this.routine = StartCoroutine(Move()); //코루틴 함수 시작 } //코루틴 (이벤트 함수) IEnumerator Mo.. 2023. 2. 2.
[Unity 3D / 유니티 교과서] 7장 예제 Bamsongi MainCamera 선택 후 Ctrl + Shift + F : Scene에서 바라보는 화면을 Game View에 출력되도록 Camera 위치 이동 Prefab Position을 (0, 0, 0)으로 변경 (reset) 후 등록하기 : 등록한 위치에서 인스턴스가 생성되기 때문 Prefab -우클릭 - Prefab - Unpack : 프리팹을 일반 오브젝트로 변경 BamsongiController using System.Collections; using System.Collections.Generic; using UnityEngine; public class BamsongiController : MonoBehaviour { private Rigidbody rbody; private ParticleSystem.. 2023. 2. 1.
[Unity 2D / 유니티 교과서] 6장 예제 ClimbCloud Rigidbody : 중력, 마찰 힘 계산 (강체) -물리 영향을 무시 : Body Type - Kinematic (기본 Dynamic) -회전을 방지 : Constraints - Freeze Rotation z활성 Collider : 충돌 판정 OnTriggerEnter2D(Colider2D) : SceneManager 자주 사용하게 될 Find method -복수형에 주의! 단수형은 처음 찾은 대상을 반환, 복수형은 배열을 반환 FindGameObjectsWithTag(태그이름) FindObjectsOfType(타입이름) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Scen.. 2023. 2. 1.
[Unity 2D] Mecanim (애니메이션 상태 시스템) 연습 처음에 SetInteger를 호출할수 없어 이유를 한참 찾았는데, Animator 타입을 Animation으로 자꾸 잘못 적었다. 항상 자세히 보기!! Animator.SetInteger(Parameter이름, Transition에 설정한 상태); Transition은 Has Exit Time, Fixed Duration 해제, 0으로 설정 : 키를 눌렀을 경우에만 transition이 일어나도록 Idle, Walk가 아닌 한번만 재생할 애니메이션은 Inspector의 Loop Time 해제 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CucumberController : MonoBeh.. 2023. 2. 1.
[Unity 2D / 유니티 교과서] 5장 예제 PlayerController using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float radius; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.RightArrow)) { this.transform.Translate(3, 0, 0); } else if (Input.GetKeyDown(KeyCode.L.. 2023. 1. 31.
[Unity 2D] 스와이프 예제 변형 StarController using System.Collections; using System.Collections.Generic; using UnityEngine; public class StarController : MonoBehaviour { private float speed = 0; private Vector2 startPos; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { this.startPos = Input.mousePosition; } else if (Input.G.. 2023. 1. 30.
728x90