Vector3 변수명 = Input.mousePosition;
현재 마우스 위치를 읽음
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class App : MonoBehaviour
{
// public Controler Controler;
void Start()
{
}
private void Update()
{
Vector3 f = Input.mousePosition;
Debug.Log($"마우스 위치: {f}");
}
}
bool i변수명 = Input.GetKeyDown(KeyCode.키);
키를 누르고 있는 동안~
bool i변수명 = Input.GetKey(KeyCode.키);
키를 누르면~
float 변수명 = Input.GetAxis("InputManager 키 이름“);
0.0000…f라 자연스러운 이동을 원할 때 사용
float 변수명 = Input.GetAxis(“Horizontal“);
키보드 화살표 가로 방향 Left, Right 누르면 -1.0f ~ +1.0
안누르면 0
float 변수명 = Input.GetAxis("Vertical");
키보드 화살표 위아래 방향 Up, Down 누르면 -1.0f ~ +1.0f
안누르면 0
KeyCode(enum)
마우스와 키보드 등 장치의 이름이 미리 정의되어있음
Edit - Preferences -InputManaguer
https://docs.unity3d.com/ScriptReference/KeyCode.html
Unity - Scripting API: KeyCode
Description Key codes returned by Event.keyCode. These map directly to a physical key on the keyboard. If "Use Physical Keys" is enabled in Input Manager settings, these map directly to a physical key on the keyboard. If "Use Physical Keys" is disabled the
docs.unity3d.com
Space, Return
RightArrow, LeftArrow
q,w,e,r
a,s,d
LeftShift
Mouse0, Mouse1,
'게임 클라이언트 프로그래밍' 카테고리의 다른 글
코루틴 (3) | 2024.09.01 |
---|---|
형 변환 (0) | 2024.08.23 |
Audio Source 등록 (0) | 2024.08.22 |
게임 오브젝트인 스크립트 컴포넌트의 매서드 실행하기 (0) | 2024.08.22 |
게임 오브젝트에 연결된 클래스에 접근 하는 방법: Inspector 직접 연결 / 접근_한정자 게임오브젝트_타입 변수명; (0) | 2024.08.21 |