Unified 3D Input is a system developed for the Innovation Inc Thermal Power Plant on Roblox to centralize multiple inputs with a common interface.
This project uses Rojo for the project structure. Two project files in included in the repository.
default.project.json
- Structure for just the module. Intended for use withrojo build
and to be included in Rojo project structures as a dependency.demo.project.json
- Full Roblox place that can be synced into Roblox studio and ran with demo models.
Unified 3D Input can be placed anywhere in the game and does not require
any additional server setup beyond setting up individual inputs. On the
client, there is optional setup depending on the inputs used. VR inputs
require client setup, which is done with the following assuming Unified3DInput
is directly in ReplicatedStorage
.
require(game:GetService("ReplicatedStorage"):WaitForChild("Unified3DInput")):SetUpClient()
Creates a Unified 3D Input.
Event that is fired when the input is activated. The input parameters are the player that activated the input and the distance the player activated it at. Due to replication delays, it may be higher than the max activation distance.
Sets the MaxActivationDistance of all the inputs. Returns itself to allow chaining.
Adds an input. The name of the input is the input type to add (included
ones are "ClickDetector"
, "ProximityPrompt"
, and "VRHandInteract"
) and
the properties is an optional table of properties to set for the inputs.
The properties for each of the included ones include:
ClickDetector
- Any property of aClickDetector
.Parent
andMaxActivationDistance
are unsupported.ProximityPrompt
- Any property of aProximityPrompt
.Parent
,MaxActivationDistance
, andEnabled
are unsupported."VRHandInteract"
- Only a bool value forDisableOtherInputs
is supported, which makes it so VR users have to physically touch the part.
Returns itself to allow chaining.
Enables the input.
Disables the input.
Destroys the input.
Custom inputs can be added to the module in the Input
folder. They are
expected to have the following implemented.
Creates the input for a Unified3DInput, which is passed in as a parameter.
Optional function that sets the properties for the input. It will be called
once when it is created with properties and when SetMaxActivationDistance
is called. If it isn't implemented, it will not be called.
Enables the input.
Disables the input.
Destroys the input.
This project is available under the terms of the MIT License. See LICENSE for details.