2025/04/03 3

유니티 - 델타타임

델타타임deltaTime코드 예시 private void Update() { Vector3 vec = new Vector3( Input.GetAxisRaw("Horizontal") * Time.deltaTime, Input.GetAxisRaw("Vertical") * Time.deltaTime); transform.Translate(vec); }Time.deltatTime: 이전 프레임의 완료까지 걸린 시간Time.deltaTime 사용 방법Translate: 백터에 곱하기Transform.Translate(vec * Time.deltaTime); Vector 함수: 시간 매개변수에 곱하기Vector3.Lerp(Vec1, Vec2, T * Time.deltaTime); deltaTi..

유니티 2025.04.03

유니티 - 목표 지점으로 이동시키기

일정한 이동using System.Collections;using System.Collections.Generic;using UnityEngine;public class gimozzi : MonoBehaviour{ Vector3 target = new Vector3(8, 1.5f, 0); void Update() { transform.position = Vector3.MoveTowards(transform.position, target, 2f); }MoveTowards: 등속 이동매개변수는 (현재위치, 목표위치, 속도)로 구성 수수숙 이동하는 느낌 부드러운 이동SmoothDamp: 부드러운 감속 이동using System.Collections;usin..

유니티 2025.04.03

유니티 - 키보드 마우스 이동

키 입력Update만 사용할 것이다.  Input: 게임 내 입력을 관리하는 클래스Input.anyKeyDown: 아무 입력을 최초로 받을 때 true코드 예시using System.Collections;using System.Collections.Generic;using UnityEngine;public class gimozzi : MonoBehaviour{ private void Update() { if (Input.anyKeyDown) { Debug.Log("플레이어가 아무 키를 눌렀다"); } }} 그 후 유니티로 들어가 게임 신에서 아무 키나 누르면 다음과 같이 나온다. Input.anyKey를 사용하면 누르고 있다는 게 된다.if (In..

유니티 2025.04.03