Sinespace Client 2025.3.19431
Client-side scripting for Sinespace
SineSpace.Scripting.Scene.SPhysics Class Reference

Public Member Functions

 SPhysics (SScript sScript)
 
SPhysicsHit[] RayCast (SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
 Raycasts from origin in direction normal.
 
SPhysicsHit RayCastSingle (SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
 Returns single raycast hit from origin in direction normal.
 
SPhysicsHit[] SphereCast (SVector origin, float radius, float distance, SVector direction, SLayerMask layerMask=null)
 Casts a sphere along a ray and returns all detailed information on what were hit.
 
SPhysicsHit[] CapsuleCast (SVector origin, SVector end, float radius, float distance, SVector up, SLayerMask layerMask=null)
 Casts a capsule against all colliders in the Scene and returns all detailed information on what were hit.
 
SPhysicsHit[] SphereCast (SVector origin, float radius, float distance, SLayerMask layerMask=null)
 
SPhysicsHit[] CapsuleCast (SVector origin, SVector end, float radius, float distance, SLayerMask layerMask=null)
 
SPhysicsHit[] BoxCast (SVector origin, SVector extents, SVector direction, SQuaternion orientation, float distance, SLayerMask layerMask=null)
 Casts the box along a ray and returns detailed information on what was hit.
 

Properties

SVector Gravity [get, set]
 The gravity applied to all rigid bodies in the Scene.
 

Constructor & Destructor Documentation

◆ SPhysics()

SineSpace.Scripting.Scene.SPhysics.SPhysics ( SScript sScript)

Member Function Documentation

◆ BoxCast()

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.BoxCast ( SVector origin,
SVector extents,
SVector direction,
SQuaternion orientation,
float distance,
SLayerMask layerMask = null )

Casts the box along a ray and returns detailed information on what was hit.

Parameters
originCenter of the box.
extentsHalf the size of the box in each dimension.
directionThe direction in which to cast the box.
orientationRotation of the box.
distanceThe max length of the cast.
layerMaskA Layer mask that is used to selectively ignore colliders when casting a capsule.
Returns
All colliders that were hit.
local trans=Space.Host.ExecutingObject
function BoxCast()
local center=trans.WorldPosition + Vector.New(0.5,0.5,0.5) –center of a cube
local extents=Vector.new(2,2,2)
local rays=Space.Physics.BoxCast(center,extents,trans.Forward,Quaternion.Identity,2)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(BoxCast)
SPhysicsHit[] BoxCast(SVector origin, SVector extents, SVector direction, SQuaternion orientation, float distance, SLayerMask layerMask=null)
Casts the box along a ray and returns detailed information on what was hit.
Definition SPhysics.cs:192

◆ CapsuleCast() [1/2]

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.CapsuleCast ( SVector origin,
SVector end,
float radius,
float distance,
SLayerMask layerMask = null )

◆ CapsuleCast() [2/2]

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.CapsuleCast ( SVector origin,
SVector end,
float radius,
float distance,
SVector up,
SLayerMask layerMask = null )

Casts a capsule against all colliders in the Scene and returns all detailed information on what were hit.

Parameters
originThe center of the sphere at the start of the capsule.
endThe center of the sphere at the end of the capsule.
radiusThe radius of the capsule.
distanceThe max length of the sweep.
upThe direction into which to sweep the capsule.
layerMaskA Layer mask that is used to selectively ignore colliders when casting a capsule.
Returns
An array of all colliders hit in the sweep.
local trans=Space.Host.ExecutingObject
function CapsuleCast()
local startp=trans.WorldPosition
local endp=startp+trans.Up*10
local rays=Space.Physics.CapsuleCast(startp,endp,1,10,trans.Up)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(CapsuleCast)
SPhysicsHit[] CapsuleCast(SVector origin, SVector end, float radius, float distance, SVector up, SLayerMask layerMask=null)
Casts a capsule against all colliders in the Scene and returns all detailed information on what were ...
Definition SPhysics.cs:139

◆ RayCast()

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.RayCast ( SVector origin,
SVector normal,
float distance,
SLayerMask layerMask = null )

Raycasts from origin in direction normal.

Parameters
originThe position the ray starts from
normalThis should be a normalized direction vector
distanceThe maximum distance the ray can travel
Returns
local trans=Space.Host.ExecutingObject
function Raycast()
local rays = Space.Physics.RayCast(trans.WorldPosition,trans.Forward,50)
if(rays~=nil and #rays>0) then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(Raycast)
SPhysicsHit[] RayCast(SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
Raycasts from origin in direction normal.
Definition SPhysics.cs:38

◆ RayCastSingle()

SPhysicsHit SineSpace.Scripting.Scene.SPhysics.RayCastSingle ( SVector origin,
SVector normal,
float distance,
SLayerMask layerMask = null )

Returns single raycast hit from origin in direction normal.

Parameters
originThe position the ray starts from
normalThis should be a normalized direction vector
distanceThe maximum distance the ray can travel
layerMaskA Layer mask that is used to selectively ignore colliders when casting a ray
local trans=Space.Host.ExecutingObject
function RaycastSingle()
local ray=Space.Physics.RayCastSingle(trans.WorldPosition,trans.Forward,50)
if(ray~=nil and ray.ContainsHit==true) then
Space.Log(ray.Object.Name)
end
end
trans.OnUpdate(RaycastSingle)
SPhysicsHit RayCastSingle(SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
Returns single raycast hit from origin in direction normal.
Definition SPhysics.cs:65

◆ SphereCast() [1/2]

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.SphereCast ( SVector origin,
float radius,
float distance,
SLayerMask layerMask = null )

◆ SphereCast() [2/2]

SPhysicsHit[] SineSpace.Scripting.Scene.SPhysics.SphereCast ( SVector origin,
float radius,
float distance,
SVector direction,
SLayerMask layerMask = null )

Casts a sphere along a ray and returns all detailed information on what were hit.

Parameters
originThe center of the sphere at the start of the sweep.
radiusThe radius of the sphere.
distanceThe max length of the sweep.
directionThe direction in which to sweep the sphere.
layerMaskA Layer mask that is used to selectively ignore colliders when casting a sphere.
Returns
An array of all colliders hit in the sweep.
local trans=Space.Host.ExecutingObject
function SphereRaycast()
local center=trans.WorldPosition + Vector.New(0.5,0.5,0.5) –center of a cube
local rays=Space.Physics.SphereCast(center,10,10,trans.Forward)
if rays~=nil and #rays>0 then
for i=0,#rays - 1 do
Space.Log(rays[i].Object.Name.." i = "..i)
end
end
end
trans.OnUpdate(SphereRaycast)
SPhysicsHit[] SphereCast(SVector origin, float radius, float distance, SVector direction, SLayerMask layerMask=null)
Casts a sphere along a ray and returns all detailed information on what were hit.
Definition SPhysics.cs:103

Property Documentation

◆ Gravity

SVector SineSpace.Scripting.Scene.SPhysics.Gravity
getset

The gravity applied to all rigid bodies in the Scene.

Space.Log(Space.Physics.Gravity.ToString())
Space.Physics.Gravity = Vector.New(0,1,0)