Unity9 [CharacterController] 캐릭터 이동 1. Documentation https://docs.unity3d.com/kr/2019.3/ScriptReference/CharacterController.Move.html CharacterController-Move - Unity 스크립팅 API A more complex move function taking absolute movement deltas. docs.unity3d.com using System.Collections; using System.Collections.Generic; using UnityEngine; public class ${className} : MonoBehaviour { CharacterController characterController; public float sp.. 2021. 7. 13. 물체 충돌 1. 물체 충돌 시 소리 재생 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ${className} : MonoBehaviour { public AudioSource collisionSound; void Start() { collisionSound = GetComponent(); } // 충돌 시 실행 private void OnCollisionEnter(Collision collision) { print("COLLISION!!!"); // 소리 재생 collisionSound.Play(); } } ※ 충돌을 하기 위해서는 Object마다 Collider Component가 반드시 있어야.. 2021. 7. 13. [GetButton] Jump using System.Collections; using System.Collections.Generic; using UnityEngine; public class ${className} : MonoBehaviour { // Update is called once per frame void Update() { if (Input.GetButton("Jump")) { GetComponent().AddForce(new Vector3(0, 80, 0)); } } } 2021. 7. 12. [GetKey] Input Keys 1. GetKey using System.Collections; using System.Collections.Generic; using UnityEngine; public class ${className} : MonoBehaviour { // Update is called once per frame void Update() { if (Input.GetKey(KeyCode.LeftArrow)) { transform.Rotate(0, 1, 0); } if (Input.GetKey(KeyCode.RightArrow)) { transform.Rotate(0, -1, 0); } } } ※ Key 입력을 한 번만 받기 위해서는 GetKeyDown method를 사용하면 된다. 2. GetAxis using Syst.. 2021. 7. 12. 이전 1 2 3 다음