# SRay

**成员** 2

|      |                         |                              |
| ---- | ----------------------- | ---------------------------- |
| 属性 | [Origin](#origin)       | The origin point of the ray. |
| 属性 | [Direction](#direction) | The direction of the ray.    |

## 属性

### Origin

[SVector](/docs/zh-Hans/scripting/client-scripting-api-reference/types/svector.md) Origin {get; }

The origin point of the ray.

示例

**Lua**

```lua
ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayOrigin = ray.Origin

```

**Lua**

```lua
  --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )

thisGameObject = Space.Host.ExecutingObject


OnUpdate = 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.Position
  end
end

thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)  

```

### Direction

[SVector](/docs/zh-Hans/scripting/client-scripting-api-reference/types/svector.md) Direction {get; }

The direction of the ray.

示例

**Lua**

```lua
ray=Space.Camera.ScreenCoordinatesToRay(Vector.New(0.5,0.5,0))
rayDirection = ray.Direction

```

**Lua**

```lua
  --this script will make this object jump to wherever you right click
--(Example: moving objects with right click )

thisGameObject = Space.Host.ExecutingObject


OnUpdate = 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.Position
  end
end

thisGameObject.SubscribeToEvents()
thisGameObject.OnUpdate(OnUpdate)  

```
