KeyboardMove
The KeyboardMove component enables precise manual positioning of GameObjects using keyboard input with smooth interpolation and configurable movement boundaries.
Overview
KeyboardMove provides interactive control over GameObject positioning in automation simulations through customizable keyboard inputs. This component is particularly useful for manual positioning tasks during commissioning, debugging object placement, or creating interactive demonstrations where users need direct control over object movement.
Important: KeyboardMove only moves the specific GameObject it is attached to, along with all of its child objects. The movement occurs in the object's local coordinate system, meaning the X, Y, and Z axes are relative to the object's current rotation and orientation, not the world coordinate system.
The component supports independent control of all three axes with dual-key combinations, allowing for complex movement patterns while maintaining precise control. This local space movement behavior makes it ideal for controlling objects that may be oriented in various directions within your scene, as the movement directions remain consistent relative to the object's own coordinate system.
💡 Hint KeyboardMove uses Unity's standard unit system where 1 unit equals 1 meter. All speed and limit values are specified in meters and meters per second.
💡 Hint KeyboardMove is designed for manual control during setup, debugging, and testing phases. It is not a Drive-based movement system and should not be used as a replacement for automated movements in production automation sequences. Use Drive components for programmed automation movements.

Properties
Movement Settings
Speed (float) Controls the movement velocity in meters per second when keys are pressed. Higher values result in faster movement, while lower values provide finer control for precise positioning tasks. The default value of 1 m/s provides a good balance for most applications.
LerpFactor (float) Determines the smoothness of movement interpolation, with higher values producing more responsive movement and lower values creating smoother, more gradual transitions. Values between 1 and 20 are recommended, with 10 being the default that works well for most scenarios. This smoothing helps create natural-looking movement without abrupt starts and stops.
Input Keys - X Axis
The X axis controls left and right movement in the object's local coordinate system.
XNegativeKey1 (KeyCode) Primary key for negative X axis movement (typically left). Default is Keypad4 for intuitive numpad control.
XNegativeKey2 (KeyCode) Optional secondary key for negative X movement. When set to a value other than None, both keys must be pressed simultaneously to trigger movement. This dual-key requirement is useful for preventing accidental movements in critical positioning tasks.
XPositiveKey1 (KeyCode) Primary key for positive X axis movement (typically right). Default is Keypad6, maintaining consistency with numpad layout.
XPositiveKey2 (KeyCode) Optional secondary key for positive X movement, following the same dual-key logic as the negative direction.
Input Keys - Y Axis
The Y axis controls vertical movement (up and down) in the object's local coordinate system.
YNegativeKey1 (KeyCode) Primary key for negative Y axis movement (typically down). Default is None, as vertical movement is often not required in automation scenarios.
YNegativeKey2 (KeyCode) Optional secondary key for negative Y movement with dual-key support.
YPositiveKey1 (KeyCode) Primary key for positive Y axis movement (typically up). Default is None.
YPositiveKey2 (KeyCode) Optional secondary key for positive Y movement.
Input Keys - Z Axis
The Z axis controls forward and backward movement in the object's local coordinate system.
ZNegativeKey1 (KeyCode) Primary key for negative Z axis movement (typically backward). Default is Keypad2 for logical numpad navigation.
ZNegativeKey2 (KeyCode) Optional secondary key for negative Z movement with dual-key functionality.
ZPositiveKey1 (KeyCode) Primary key for positive Z axis movement (typically forward). Default is Keypad8, completing the intuitive numpad control scheme.
ZPositiveKey2 (KeyCode) Optional secondary key for positive Z movement.
Reset Control
ResetKey (KeyCode) Key used to instantly reset the GameObject to its initial position. Default is Keypad5, providing quick access to return to the starting position during positioning tasks. This feature is particularly useful when you need to quickly return to a known reference point after extensive movement.
Movement Limits
All movement limits are specified relative to the GameObject's initial position when the component starts.
XAxisLimits (Vector2) Defines the minimum (x) and maximum (y) allowed positions along the X axis in meters from the initial position. The default range of -10 to +10 meters provides ample movement space while preventing objects from moving too far from their starting point.
YAxisLimits (Vector2) Sets the vertical movement boundaries in meters from the initial position. These limits ensure objects remain within designated height ranges, particularly important for crane systems or vertical lift mechanisms.
ZAxisLimits (Vector2) Establishes forward and backward movement boundaries in meters from the initial position. These constraints are essential for preventing collisions and keeping objects within their operational areas.
Editor Tools
Visual Gizmos
When the GameObject with KeyboardMove is selected in the Unity Editor, cyan wireframe boundaries visualize the allowed movement area. This wireframe cube shows the exact limits defined by the axis limit properties, making it easy to understand and adjust the movement constraints.
A yellow sphere marks the initial position (center point) of the movement area, providing a clear reference for the origin of all movement calculations. During play mode, a red sphere indicates the current target position, helping debug movement behavior and verify that limits are working correctly.
Usage Examples
Basic Setup for Manual Positioning
Add the KeyboardMove component to any GameObject you want to control
Configure the Speed to match your desired movement rate (1-5 m/s for general use)
Adjust LerpFactor for movement smoothness (5-10 for smooth motion, 15-20 for responsive control)
Set appropriate Movement Limits based on your scene constraints
Press Play and use the configured keys to move the object
Numpad Control Configuration
The default configuration uses the numpad for intuitive movement control:
Numpad 4/6: Left/Right movement (X axis)
Numpad 8/2: Forward/Backward movement (Z axis)
Numpad 5: Reset to initial position
Y axis keys can be configured if vertical control is needed
This layout mirrors common industrial control panels and provides logical spatial mapping.
Dual-Key Safety Setup
For critical positioning tasks where accidental movement must be prevented:
Set XNegativeKey2 to LeftShift or LeftControl
Set XPositiveKey2 to the same modifier key
Repeat for Y and Z axes as needed
Movement now requires holding the modifier key plus the direction key
This configuration ensures deliberate control actions and prevents unintended movements.
Last updated