Returns true if 'key' was pressed during this frame.
Parameter
Type
Description
key
string
thisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetKeyDown("space") then Space.Log("Jump Key Down")endendthisGameObject.OnUpdate(OnUpdate)
GetKeyUp
bool GetKeyUp (string key)
Returns true if 'key' is no longer pressed during this frame (but was in the last).
Parameter
Type
Description
key
string
thisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetKeyUp("space") then Space.Log("Jump Key Released")endendthisGameObject.OnUpdate(OnUpdate)
GetKey
bool GetKey (string key)
Returns true if 'key' is being held pressed.
Parameter
Type
Description
key
bool
thisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetKey("space") then Space.Log("Jump Key Held")endendthisGameObject.OnUpdate(OnUpdate)
GetMouseDown
bool GetMouseDown (int button)
Returns true if mouse 'button' was pressed during this frame.
Parameter
Type
Description
button
int
button values are 0 for the primary button (often the left button), 1 for secondary button, and 2 for the middle button.
if Space.Input.GetMouseDown(1) then Space.Log("Right Mouse button pressed in this frame")end
--this script will make this object jump to wherever you right clickthisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetMouseDown(1) then clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition) rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0) thisGameObject.WorldPosition = rayCastHit.PositionendendthisGameObject.OnUpdate(OnUpdate)
GetMouseUp
bool GetMouseUp (int button)
Returns true if mouse 'button' is no longer pressed during this frame (but was in the last).
Parameter
Type
Description
button
int
button values are 0 for the primary button (often the left button), 1 for secondary button, and 2 for the middle button.
if Space.Input.GetMouseUp(1) then Space.Log("Right Mouse button was just unpressed")end
GetMouseHold
bool GetMouseHold (int button)
Returns true if mouse 'button' is being held pressed.
Parameter
Type
Description
button
int
button values are 0 for the primary button (often the left button), 1 for secondary button, and 2 for the middle button.
if Space.Input.GetMouseHold(1) then Space.Log("Right Mouse button being held")end
--this script will make this object will follow your ovement while holding right clickthisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetMouseHold(1) then clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition) rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0) thisGameObject.WorldPosition = rayCastHit.PositionendendthisGameObject.OnUpdate(OnUpdate)
Vibrates the controller (or phone, or gamepad) if a rumble device is present.
Parameter
Type
Description
intensity
float
Intensity of the vibration from 0.0 to 1.0
duration
float
Duration of the vibration. Maximum 1.0 second.
leftHand
bool
If true the vibration will be on the left hand and if false on the right hand (where applicable)
Space.Input.Vibrate(1,1,false)
Properties
ScrollWheel
float ScrollWheelget
Returns a non-0 value if the mouse wheel is being scrolled, value usually ranges from -1 to 1**.**
scrollWheel = Space.Input.ScrollWheel
--Object will move up and down with scroll wheel movementthisGameObject = Space.Host.ExecutingObjectOnUpdate=function() thisGameObject.WorldPosition = thisGameObject.WorldPosition + (thisGameObject.Up * Space.Input.ScrollWheel)endthisGameObject.OnUpdate(OnUpdate)
Returns the current position of the mouse in screen pixels. If on a touch screen device, this will also return the location of the first finger being pressed.
currentMousePos = Space.Input.MousePosition
--Object will follow your mouse movement while holding right clickthisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.GetMouseHold(1) then clickRay = Space.Camera.ScreenCoordinatesToRay(Space.Input.MousePosition) rayCastHit = Space.Physics.RayCastSingle(clickRay.Origin, clickRay.Direction, 50.0) thisGameObject.WorldPosition = rayCastHit.PositionendendthisGameObject.OnUpdate(OnUpdate)
Returns the Turn Axis (-1 to 1 on Vector's X value).
turnAxis = Space.Input.TurnAxis
--makes this object color red if player is turning left--and color green if player is turning right--and blue if player is not turningthisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.TurnAxis.X >0then thisGameObject.Renderer.Material.SetColor("_Color",Color.Red)elseif Space.Input.TurnAxis.X <0then thisGameObject.Renderer.Material.SetColor("_Color",Color.Green)elseif Space.Input.TurnAxis.X ==0then thisGameObject.Renderer.Material.SetColor("_Color",Color.Blue)endendthisGameObject.OnUpdate(OnUpdate)
MouseLook
bool MouseLookgetset
Enable or disable Mouse Look feature.
Space.Input.MouseLook =true
--the below script will put your player into MouseLook mode if you are near the object --and return you to normal mode if you are far from the object thisGameObject = Space.Host.ExecutingObjectfunctionOnUpdate() positionAvatar = Space.Scene.PlayerAvatar.GameObject.WorldPosition positionObject = thisGameObject.WorldPositionif positionAvatar.InRange(positionObject, 5.0) thenif Space.Input.MouseLook ==falsethen Space.Input.MouseLook =trueendelseif Space.Input.MouseLook ==truethen Space.Input.MouseLook =falseendendendthisGameObject.OnUpdate(OnUpdate)
MouseX
float MouseXget
Returns a float representing the Mouse/Right Joystick horizontal movement. If the value is positive the movement is upwards. If the value is negative the movement is downwards. The value is derived by multiplying mouse delta with axis sensitivity. This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.
MouseX = Space.Input.MouseX
--the below script will rotate this object along the Y axis --according to your mouse/right joystick horizontal movementthisGameObject = Space.Host.ExecutingObjectfunctionOnUpdate() currentY = thisGameObject.WorldRotation.EulerAngles.Y newY = currentY + Space.Input.MouseX thisGameObject.WorldRotation = Quaternion.Euler(0, newY, 0)endthisGameObject.OnUpdate(OnUpdate)
MouseY
float MouseYget
Returns a float representing the Mouse/Right Joystick vertical movement. If the value is positive the movement is to the right. If the value is negative the movement is to the left. The value is derived by multiplying mouse delta with axis sensitivity. This is frame-rate independent; you do not need to be concerned about varying frame-rates when using this value.
MouseY = Space.Input.MouseY
--the below script will rotate this object along the Y axis --according to your mouse/right joystick vertical movementthisGameObject = Space.Host.ExecutingObjectfunctionOnUpdate() currentX = thisGameObject.WorldRotation.EulerAngles.X newX = currentX + Space.Input.MouseY thisGameObject.WorldRotation = Quaternion.Euler(newX , 0, 0)endthisGameObject.OnUpdate(OnUpdate)
Returns the Turn Axis (-1 to 1 on Vector's X value).
turnAxis = Space.Input.TurnAxis
--makes this object color red if player is turning left
Fire
bool Fireget
Return true if primary fire is pressed (Mouselook Mode).
fireIsPressed = Space.Input.Fire
--Create a GameObject from resource when Primary Fire button is pressed--[Add resource "bullet" as a resource in scripting runtime component]thisGameObject = Space.Host.ExecutingObjectbullet = Space.GetResource("bullet") OnUpdate=function()if Space.Input.Fire then Space.Scene.CreateGameObject(bullet) endendthisGameObject.OnUpdate(OnUpdate)
AltFire
bool AltFireget
Return true if alternative fire is pressed (Mouselook Mode)
altFireIsPressed = Space.Input.AltFire
--Create a GameObject from resource when Alternate Fire button is pressed--[Add resource "bullet" as a resource in scripting runtime component]thisGameObject = Space.Host.ExecutingObjectbullet = Space.GetResource("bullet") OnUpdate=function()if Space.Input.AltFire then Space.Scene.CreateGameObject(bullet) endendthisGameObject.OnUpdate(OnUpdate)
CursorInUI
bool CursorInUIget
Returns true if the cursor is over the Sinespace UI.
cursorInUI = Space.Input.CursorInUI
--this object is going to listen to your scroll wheel movement and move accordingly--UNLESS your cursor is on the sinespace UI--(Example: Scrolling chat won't also move the object)thisGameObject = Space.Host.ExecutingObjectOnUpdate=function()if Space.Input.CursorInUI ==falsethen thisGameObject.WorldPosition = thisGameObject.WorldPosition + (thisGameObject.Up * Space.Input.ScrollWheel)endendthisGameObject.OnUpdate(OnUpdate)