The InputObject class represents a single user input, such as mouse movement, key presses, touch interactions, or gamepad inputs. It is created when an input begins and persists throughout the lifetime of that input, updating its properties as the input changes. This class is essential for handling and tracking user interactions.
Description
The InputObject class provides detailed information about a specific user input event. It is used in conjunction with services like UserInputService and ContextActionService, as well as GUI-related events, to detect and respond to user actions.
Properties
Delta
Vector3
Delta is a property of type vector3 representing the change in position or movement primarily used to track touch movements.
Code Samples
local ContextActionService = game:GetService("ContextActionService")local ActionName ="JumpAction"local IsCreateTouchButton =truelocal KeyCode = Enum.KeyCode.FlocalfunctionOnAction(actionName,inputState,inputObject) if inputState == Enum.UserInputState.Change thenprint(inputObject.Delta)endendContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)
KeyCode
Enum.KeyCode
KeyCode is a property of type Enum.KeyCode representing the specific key or button pressed during user input events.
Position is a property representing the positional value or current location of an input event.
Code Samples
local ContextActionService = game:GetService("ContextActionService")local ActionName ="JumpAction"local IsCreateTouchButton =truelocal KeyCode = Enum.KeyCode.FlocalfunctionOnAction(actionName,inputState,inputObject) if inputState == Enum.UserInputState.Change thenprint(inputObject.Position)endendContextActionService:BindAction(ActionName, OnAction, IsCreateTouchButton, KeyCode)
UserInputState
Enum.UserInputState
UserInputState indicates the current state of an input being performed, which may include pressed, released, held, pending, or other distinct stages defined by the associated UserInputType.