|
Sinespace Client
2023.2.17543
Client-side scripting for Sinespace
|
|
| 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...
|
|
◆ SPhysics()
SineSpace.Scripting.Scene.SPhysics.SPhysics |
( |
SScript |
sScript | ) |
|
◆ BoxCast()
Casts the box along a ray and returns detailed information on what was hit.
- Parameters
-
origin | Center of the box. |
extents | Half the size of the box in each dimension. |
direction | The direction in which to cast the box. |
orientation | Rotation of the box. |
distance | The max length of the cast. |
layerMask | A Layer mask that is used to selectively ignore colliders when casting a capsule. |
- Returns
- All colliders that were hit.
local trans=Space.Host.ExecutingObject
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
◆ CapsuleCast() [1/2]
◆ CapsuleCast() [2/2]
Casts a capsule against all colliders in the Scene and returns all detailed information on what were hit.
- Parameters
-
origin | The center of the sphere at the start of the capsule. |
end | The center of the sphere at the end of the capsule. |
radius | The radius of the capsule. |
distance | The max length of the sweep. |
up | The direction into which to sweep the capsule. |
layerMask | A 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
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
◆ RayCast()
Raycasts from origin in direction normal
- Parameters
-
origin | The position the ray starts from |
normal | This should be a normalized direction vector |
distance | The 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()
Returns single raycast hit from origin in direction normal
- Parameters
-
origin | The position the ray starts from |
normal | This should be a normalized direction vector |
distance | The maximum distance the ray can travel |
layerMask | A 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]
◆ SphereCast() [2/2]
Casts a sphere along a ray and returns all detailed information on what were hit.
- Parameters
-
origin | The center of the sphere at the start of the sweep. |
radius | The radius of the sphere. |
distance | The max length of the sweep. |
direction | The direction in which to sweep the sphere. |
layerMask | A 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)
◆ 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)
SPhysicsHit[] RayCast(SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
Raycasts from origin in direction normal
Definition: SPhysics.cs:38
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
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
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
SPhysicsHit RayCastSingle(SVector origin, SVector normal, float distance, SLayerMask layerMask=null)
Returns single raycast hit from origin in direction normal
Definition: SPhysics.cs:65