본문 바로가기
728x90

Unity47

[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장 예제 + 이동범위 제한 Mathf.Clamp(value, min, max)를 사용하여 x좌표 이동범위 제한 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() { float posX = Mathf.Clamp(transform.position.x, -8.0f, 8.0f); if (Input.GetKeyDown(KeyC.. 2023. 1. 31.
[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.
728x90