Sinespace Client  2023.2.17543
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 More...
 
SPhysicsHit RayCastSingle (SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
 Returns single raycast hit from origin in direction normal More...
 
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. More...
 
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. More...
 
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. More...
 

Properties

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

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)

◆ 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)

◆ 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)

◆ 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)

◆ 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)

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)
SineSpace.Scripting.Scene.SPhysics.RayCast
SPhysicsHit[] RayCast(SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
Raycasts from origin in direction normal
Definition: SPhysics.cs:38
SineSpace.Scripting.Scene.SPhysics.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
SineSpace.Scripting.Scene.SPhysics.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
SineSpace.Scripting.Scene.SPhysics.SphereCast
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
SineSpace.Scripting.Scene.SPhysics.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