UserInputService
UserInputService : Instance
Overview
์ฌ์ฉ์์ ์ฅ์น์์ ๋ฐ์ํ๋ ์ ๋ ฅ์ ๊ฐ์งํ ์ ์๋๋ก ๋์์ฃผ๋ ํด๋ผ์ด์ธํธ ์ ์ฉ ์๋น์ค์ ๋๋ค.
ํค๋ณด๋, ๋ง์ฐ์ค, ํฐ์น์คํฌ๋ฆฐ ๋ฑ ์ ๋ ฅ ์ฅ์น์ ๋ฐ๋ผ ๋์์ ๋ค๋ฅด๊ฒ ์ฒ๋ฆฌํ ์ ์์ด ํ๋ซํผ์ ์ต์ ํ๋ ์ฌ์ฉ์ ๊ฒฝํ์ ๊ตฌํํ ์ ์์ต๋๋ค.
์ด ์๋น์ค๋ LocalScript์ ๊ฐ์ ํด๋ผ์ด์ธํธ ํ๊ฒฝ์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
Properties
Methods
Events
TouchStarted
์ฌ์ฉ์๊ฐ ํ๋ฉด์ ํฐ์น ํ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค.
ํฐ์น ๊ธฐ๋ฐ ์ธํฐ๋์ ์ ์์์ ์ ๊ฐ์งํ๋ ๋ฐ ์ ์ฉํ๋ฉฐ, TouchMoved์ TouchEnded์ ํจ๊ป ์ฌ์ฉํ๋ฉด, ํฐ์น์ ์์๋ถํฐ ์ด๋, ์ข ๋ฃ๊น์ง์ ์ ์ฒด ๊ณผ์ ์ ํจ๊ณผ์ ์ผ๋ก ์ถ์ ํ ์ ์์ต๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ํฐ์น ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ฉํฐ ํฐ์น์ ๊ฒฝ์ฐ, ์ด ๊ฐ์ฒด๋ค์ ๋น๊ตํ๋ ๋ฐฉ์์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํคEnum.UserInputState
UserInputState: ์ ๋ ฅ ์ํEnum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅVector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchStart(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
TouchMoved
์ฌ์ฉ์๊ฐ ํ๋ฉด ์์์ ์๊ฐ๋ฝ์ ์์ง์ผ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค.
์๊ฐ๋ฝ์ด ์ด๋ ์์น๋ก ์ด๋ํ๊ณ ์๋์ง๋ฅผ ์ค์๊ฐ์ผ๋ก ์ถ์ ํ ์ ์์ด, ๋๋๊ทธ, ์ค์์ดํ์ ๊ฐ์ ์ ์ค์ฒ ๊ธฐ๋ฐ ์ ๋ ฅ์ ๊ฐ์งํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ํฐ์น ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ฉํฐ ํฐ์น์ ๊ฒฝ์ฐ, ์ด ๊ฐ์ฒด๋ค์ ๋น๊ตํ๋ ๋ฐฉ์์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํค
Enum.UserInputState
UserInputState: ์ ๋ ฅ ์ํ
Enum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅ
Vector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchMove(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.TouchMoved:Connect(OnScreenTouchMove)
TouchEnded
์ฌ์ฉ์๊ฐ ํ๋ฉด์์ ์๊ฐ๋ฝ์ ๋ผ๋ ์๊ฐ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค.
์ด ์ด๋ฒคํธ๋ ํฐ์น ์ ๋ ฅ์ ์ข ๋ฃ ์์ ์ ๊ฐ์งํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ํฐ์น ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ฉํฐ ํฐ์น์ ๊ฒฝ์ฐ, ์ด ๊ฐ์ฒด๋ค์ ๋น๊ตํ๋ ๋ฐฉ์์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํค
Enum.UserInputState
UserInputState: ์ ๋ ฅ ์ํ
Enum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅ
Vector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchEnd(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.TouchEnded:Connect(OnScreenTouchEnd)
InputBegan
์ฌ์ฉ์๊ฐ ํ๋ฉด์ ํด๋ฆญํ๊ฑฐ๋, ๋ง์ฐ์ค, ํค๋ณด๋ ๋ฑ์ผ๋ก ์ ๋ ฅ์ ์์ํ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค.
InputChanged์ InputEnded์ ํจ๊ป ์ฌ์ฉํ๋ฉด, ์ ๋ ฅ์ ์์๋ถํฐ ์ด๋, ์ข ๋ฃ๊น์ง์ ์ ์ฒด ๊ณผ์ ์ ํจ๊ณผ์ ์ผ๋ก ์ถ์ ํ ์ ์์ต๋๋ค.
๋ค๋ง, ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ ์ฌ์ฉ์ ๊ถ์ฅํ์ง ์์ผ๋ฉฐ, ์คํ๋์ค์์์ ํ ์คํธ๋ ์๋ฎฌ๋ ์ด์ ์ฉ๋๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ ํฉํฉ๋๋ค. ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ TouchStarted, TouchMoved, TouchEnded ์ด๋ฒคํธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํคEnum.UserInputState
UserInputState: ์ ๋ ฅ ์ํEnum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅVector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchStart(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.InputBegan:Connect(OnScreenTouchStart)
InputChanged
์ฌ์ฉ์๊ฐ ํ๋ฉด์ ํด๋ฆญํ ์ํ์์ ๋ง์ฐ์ค ์ปค์๋ฅผ ์์ง์ผ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค
๋ง์ฐ์ค ์ปค์๊ฐ ์ด๋ ์์น๋ก ์ด๋ํ๊ณ ์๋์ง๋ฅผ ์ค์๊ฐ์ผ๋ก ์ถ์ ํ ์ ์์ด, ๋๋๊ทธ, ์ค์์ดํ์ ๊ฐ์ ์ ์ค์ฒ ๊ธฐ๋ฐ ์ ๋ ฅ์ ๊ฐ์งํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
๋ค๋ง, ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ ์ฌ์ฉ์ ๊ถ์ฅํ์ง ์์ผ๋ฉฐ, ์คํ๋์ค์์์ ํ ์คํธ๋ ์๋ฎฌ๋ ์ด์ ์ฉ๋๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ ํฉํฉ๋๋ค. ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ TouchStarted, TouchMoved, TouchEnded ์ด๋ฒคํธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํคEnum.UserInputState
UserInputState: ์ ๋ ฅ ์ํEnum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅVector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchMove(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.InputChanged:Connect(OnScreenTouchMove)
InputEnded
์ฌ์ฉ์๊ฐ ํ๋ฉด ํด๋ฆญ, ๋ง์ฐ์ค, ํค๋ณด๋ ๋ฑ์ ์ ๋ ฅ์ ์ข ๋ฃํ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ๋๋ค.
์ด ์ด๋ฒคํธ๋ ์ ๋ ฅ์ ์ข ๋ฃ ์์ ์ ๊ฐ์งํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
๋ค๋ง, ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ ์ฌ์ฉ์ ๊ถ์ฅํ์ง ์์ผ๋ฉฐ, ์คํ๋์ค์์์ ํ ์คํธ๋ ์๋ฎฌ๋ ์ด์ ์ฉ๋๋ก ์ฌ์ฉํ๋ ๊ฒ์ด ์ ํฉํฉ๋๋ค. ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์๋ TouchStarted, TouchMoved, TouchEnded ์ด๋ฒคํธ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๊ถ์ฅ๋ฉ๋๋ค.
Parameters
InputObject
InputObject
์ ๋ ฅ๊ณผ ๊ด๋ จ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ ๊ฐ์ฒด์ด๋ฉฐ, ํ๋์ ์ ๋ ฅ์ด ์์๋๊ณ ๋๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋ฉ๋๋ค.
Enum.KeyCode
KeyCode: ์ ๋ ฅ๋ ํคEnum.UserInputState
UserInputState: ์ ๋ ฅ ์ํEnum.UserInputType
UserInputType: ์ ๋ ฅ ์ฅ์น ์ข ๋ฅVector3
Delta: ์ด๋ ๋ณํ๋ (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )Vector3
Position: ์ ๋ ฅ์ด ๋ฐ์ํ ํ๋ฉด์์ ์์น (Z๊ฐ์ 0์ผ๋ก ๊ณ ์ )
bool
bGameProcessed
ํด๋น ์ ๋ ฅ์ด ํ๋ฉด ์์ UI ์์์ ์ํด ์ด๋ฏธ ์ฒ๋ฆฌ๋์๋์ง๋ฅผ ๋ํ๋ ๋๋ค. ์ ๋ ฅ์ ์ํฅ์ ์ค ์ ์๋ UI๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
์ฑํ ์ฐฝ, ๋ฉ๋ด ๋ฒํผ ๊ฐ์ ์์คํ UI
ContextActionService๋ก Bind๋ ๋ฒํผ
ScreenGui, SurfaceGui๋ด Active๊ฐ ์ผ์ง Gui ๋ฒํผ
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchEnd(input, _gameProcessed)
local keyCode = input.KeyCode
local inputState = input.UserInputState
local inputType = input.UserInputType
local delta = input.Delta
local pos = input.Position
end
UserInputService.InputEnded:Connect(OnScreenTouchEnd)
See also
๋ชจ๋ฐ์ผ ์กฐ์ ์ฒ๋ฆฌLast updated