본문 바로가기
728x90

Unity/수업내용11

[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 / 유니티 교과서] 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.
[Unity 2D / 유니티 교과서] 4장 예제 SwipeCar AudioSource mp3파일이 아닌 ogg파일로 변경해서 사용하기! ( 용량 최소 약 1/5로 줄음) Input.mousePosition Unity공간 좌표가 아니라 실행화면의 Screen(픽셀공간) 좌표 죄표계는 3D, Screen, UI 각각 존재 Awake 이벤트 함수. (활성화된 오브젝트에서!)인스턴스 생성 직후 실행. Start보다 먼저 실행 transform.Translate(x, y, z, Space.self/world) 로컬 좌표. 월드 좌표GameObject.Find("string") Scene안에 있는 GameObject 이름 검색(오타 주의) CarController using System.Collections; using System.Collections.Generic; usin.. 2023. 1. 30.
[Unity 2D / 유니티교과서] 3장 예제 Roulette using System.Collections; using System.Collections.Generic; using UnityEngine; public class RouletteController : MonoBehaviour { private float rotSpeed = 0; public float attenuation = 0.96f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { this.rotSpeed = 10; } //오브젝트를 회전 하는 방법 //회전은 Transform이.. 2023. 1. 30.
728x90