InputObject
InputObject : Instance
Overview
ํ๋ฉด ํฐ์น๋ ๋ง์ฐ์ค, ํค๋ณด๋ ์ ๋ ฅ ๋ฑ ์ฌ์ฉ์ ์ ๋ ฅ์ด ๋ฐ์ํ ๋ ์์ฑ๋๋ ๊ฐ์ฒด์ ๋๋ค.
์ฌ์ฉ์์ ์ ๋ ฅ ์ ํ(UserInputType)์ ์ ๋ ฅ ์ํ(UserInputState), ์ ๋ ฅ๋ ํค(KeyCode)์ ์ ๋ ฅ ์์น(Position) ๋ฑ์ ์์ฑ์ ํตํด ์ ๋ ฅ์ ์ธ๋ถ ์ฌํญ์ ํ์ธํ ์ ์์ต๋๋ค.
์ด ๊ฐ์ฒด๋ ๋ค์๊ณผ ๊ฐ์ ์ด๋ฒคํธ์์ ์์ฑ๋ฉ๋๋ค:
UserInputService์ TouchStarted, TouchMoved, TouchEnded
UserInputService์ InputBegan, InputChanged, InputEnded
ContextActionService์ BindAction()์ ์ฐ๊ฒฐ๋ ํจ์
GuiButton์ InputBegan, InputChanged, InputEnded ์ด๋ฒคํธ
์ด ๊ฐ์ฒด๋ ์ ๋ ฅ์ด ์์๋๋ ์์ ๋ถํฐ ์ข ๋ฃ๋ ๋๊น์ง ๋์ผํ ์ธ์คํด์ค๋ก ์ ์ง๋๋ฉฐ, ์ ๋ ฅ ์ค ์ํ ๋ณํ๋Changed ์ด๋ฒคํธ๋ฅผ ํตํด ๊ฐ์งํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด ํ์ฌ ํ์ฑํ๋ ์ ๋ ฅ๋ค์ ๋ฆฌ์คํธ๋ก ๊ด๋ฆฌํ๊ฑฐ๋ ํด๋น ์ ๋ ฅ์ ๋ํด ๊ณ์ ์ถ์ ๋ฐ ์ ์ดํ ์ ์๊ณ , ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์ ๊ฐ ์๊ฐ๋ฝ ์ ๋ ฅ์ ๊ตฌ๋ถํ์ฌ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
InputObject๋ UserInputService์ ์ด๋ฒคํธ๋ GuiObject์ ์ ๋ ฅ ์ฒ๋ฆฌ์ ์ฐ๊ณ๋์ด ์ฌ์ฉ๋ฉ๋๋ค.
Properties
Delta
Vector3
์ ๋ ฅ ์์น์ ๋ณํ๋์ ๋ํ๋ด๋ ๊ฐ์ผ๋ก, Position ์์ฑ๊ณผ ํจ๊ป ์ฌ์ฉํ๋ฉด ์ ๋ ฅ ๊ฒฝ๋ก๋ฅผ ์ถ์ ํ ์ ์์ด ์นด๋ฉ๋ผ ์ด๋์ด๋ ์บ๋ฆญํฐ ์กฐ์๊ณผ ๊ฐ์ ๊ตฌํ์์ ์ ์ฉํ๊ฒ ํ์ฉ๋ฉ๋๋ค.
๋จ, ํค๋ณด๋ ์ ๋ ฅ์ฒ๋ผ ์์น ์ ๋ณด๊ฐ ์๋ ์ ๋ ฅ ์ ํ์ ๊ฒฝ์ฐ, Delta๋ Position๋ ์ ๋ ฅ ์์ ๋ฐ ์ข ๋ฃ ์ด๋ฒคํธ์์๋ง ํ์ธํ ์ ์์ต๋๋ค.
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
print("KeyCode : ", keyCode)
print("InputState : ", inputState)
print("InputType : ", inputType)
print("Delta : ", delta)
print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
KeyCode
Enum.KeyCode
์ ๋ ฅ์ ์ฌ์ฉ๋ ํค ์ ๋ณด๋ฅผ ๋ํ๋ด๋ ๊ฐ์ผ๋ก, ๋ชจ๋ฐ์ผ ํ๊ฒฝ์์ ํฐ์น ์ ๋ ฅ๊ณผ ๊ฐ์ ์กฐ์ด์คํฑ ์ ๋ ฅ์ ๊ตฌ๋ถํ๋ ์ฉ๋๋ก๋ ํ์ฉํ ์ ์์ต๋๋ค.
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
print("KeyCode : ", keyCode)
print("InputState : ", inputState)
print("InputType : ", inputType)
print("Delta : ", delta)
print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
Position
Vector3
์ ๋ ฅ ์์น๋ฅผ ๋ํ๋ด๋ ๊ฐ์ผ๋ก, ๋ง์ฐ์ค๋ ํฐ์น ์ ๋ ฅ์ X, Y ์ขํ๋ ํ๋ฉด์์ ์ขํ๋ฅผ ์๋ฏธํฉ๋๋ค.
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
print("KeyCode : ", keyCode)
print("InputState : ", inputState)
print("InputType : ", inputType)
print("Delta : ", delta)
print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
UserInputState
Enum.UserInputState
์ ๋ ฅ์ ์งํ ์ํ๋ฅผ ๋ํ๋ด๋ ๊ฐ์ผ๋ก, ์์, ๋ณ๊ฒฝ, ์ข ๋ฃ, ์ทจ์ ๋ฑ ์ํ๋ฅผ ๊ตฌ๋ถํ์ฌ ์ ๋ ฅ์ ํ๋ฆ์ ์ถ์ ํ๊ฑฐ๋ ์ํ์ ๋ฐ๋ฅธ ์ฒ๋ฆฌ๋ฅผ ๊ตฌํํ ๋ ์ ์ฉํ๊ฒ ํ์ฉ๋ฉ๋๋ค.
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchStart(input, _gameProcessed)
local inputState = input.UserInputState
print("InputState : ", inputState) -- Begin
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
local function OnScreenTouchMove(input, _gameProcessed)
local inputState = input.UserInputState
print("InputState : ", inputState) -- Change
end
UserInputService.TouchMoved:Connect(OnScreenTouchMove)
local function OnScreenTouchEnd(input, _gameProcessed)
local inputState = input.UserInputState
print("InputState : ", inputState) -- End
end
UserInputService.TouchEnded:Connect(OnScreenTouchEnd)
UserInputType
Enum.UserInputType
์ ๋ ฅ์ ์ข ๋ฅ๋ฅผ ๋ํ๋ด๋ ๊ฐ์ผ๋ก, ํฐ์น, ํค๋ณด๋, ๋ง์ฐ์ค ๋ฑ ๋ค์ํ ์ ๋ ฅ ๋ฐฉ์์ ๊ตฌ๋ถํ ์ ์์ผ๋ฉฐ, KeyCode์๋ ๋ณ๋๋ก ์ ๋ ฅ ์ ํ์ ํ๋ณํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
Code Samples
local UserInputService = game:GetService("UserInputService")
local function OnScreenTouchStart(input, _gameProcessed)
local inputType = input.UserInputType
print("InputType : ", inputType) -- Touch
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
Methods
Events
See also
๋ชจ๋ฐ์ผ ์กฐ์ ์ฒ๋ฆฌLast updated