wiki.sine.space | sinespace

Difference between revisions of "Scripting/SCharacterController"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/scharactercontroller")
 
Line 1: Line 1:
=Members=
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/scharactercontroller
 
+
{{ScriptFunction|SVector|ClosestPointOnBounds|(SVector position);|The closest point to the bounding box of the attached collider. This can be used to calculate hit points when applying explosion damage.|5=
+
function PrintVector (data)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.X)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Y)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Z)<br>
+
end<br>
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
local newVector = Vector.New(5,5,5)<br>
+
local Vectordata = Object.CharacterController.ClosestPointOnBounds(newVector)<br>
+
PrintVector(Vectordata)
+
}}
+
 
+
{{ScriptFunction|SVector|ClosestPoint|(SVector position);|The point on the collider that is closest to the specified location.|5=
+
function PrintVector (data)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.X)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Y)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Z)<br>
+
end<br>
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
local newVector = Vector.New(5,5,5)<br>
+
local Vectordata = Object.CharacterController.ClosestPoint(newVector)<br>
+
PrintVector(Vectordata)
+
}}
+
 
+
{{ScriptFunction|bool|SimpleMove|(SVector speed)|Moves the character with speed.|5=
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
local newVector = Vector.New(100,0,0)<br>
+
local Vectordata = Object.CharacterController.SimpleMove(newVector)<br>
+
Space.Log(Vectordata)
+
}}
+
 
+
{{ScriptFunction|int|Move|(SVector motion)|Moves the character with speed.|5=
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
local newVector = Vector.New(100,0,0)<br>
+
local Vectordata = Object.CharacterController.Move(newVector)<br>
+
Space.Log(Vectordata)
+
}}
+
 
+
=Properties=
+
 
+
{{ScriptFunction|SVector|Center|{get; set;}|Returns Center Vector value of the Character Controller.|5=
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
Space.Log(Object.CharacterController.Center.X)
+
}}
+
 
+
{{ScriptFunction|bool|DetectCollisions|{get; set;}|Determines whether other rigidbodies or character controllers collide with this character controller (by default this is always enabled).
+
 
+
This method does not affect collisions detected during the character controller's movement but rather decides whether an incoming collider will be blocked by the controller's collider. For example, a box collider in the Scene will block the movement of the controller, but the box may still fall through the controller if detectCollisions is false. This property is useful to disable the character controller temporarily. For example, you might want to mount a character into a car and disable collision detection until it exits the car again.|5=<pre>
+
Space.Host.CharacterController.DetectCollisions= false</pre>|6=<pre>--clicking this object will toggle a Character Controller's Detect Collisions property
+
 
+
thisObject = Space.Host.ExecutingObject
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController --add Reference to Scripting Runtime
+
 
+
 
+
function OnClickFunction()
+
ccontroller.DetectCollisions = not ccontroller.DetectCollisions
+
end
+
 
+
thisObject.AddClickable()
+
thisObject.Clickable.OnClick(OnClickFunction)</pre>
+
}}
+
 
+
{{ScriptFunction|bool|EnableOverlapRecovery|{get; set;}|Enables or disables overlap recovery. Enables or disables overlap recovery. Used to depenetrate character controllers from static objects when an overlap is detected.
+
 
+
Overlap recovery can be used to depenetrate character controllers (CCTs) from static objects when an overlap is detected. This can happen in three main cases:
+
 
+
- when the CCT is directly spawned or teleported in another object
+
 
+
- when the CCT algorithm fails due to limited FPU accuracy
+
 
+
- when the "up vector" is modified, making the rotated CCT shape overlap surrounding objects
+
 
+
When activated, the CCT module will automatically try to resolve the penetration, and move the CCT to a safe place where it does
+
 
+
not overlap other objects anymore. This only concerns static objects, dynamic objects are ignored by overlap recovery.
+
 
+
When overlap recovery is not activated, it is possible for the CCTs to go through static objects. By default, overlap recovery is enabled.
+
 
+
Overlap recovery currently works with all geometries except heightfields.|5=<pre>
+
Space.Host.CharacterController.EnableOverlapRecovery= false</pre>|6=<pre>--clicking this object will toggle a Character Controller's Enable Overlap Recovery property
+
 
+
thisObject = Space.Host.ExecutingObject
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController --add Reference to Scripting Runtime
+
 
+
 
+
function OnClickFunction()
+
ccontroller.EnableOverlapRecovery = not ccontroller.EnableOverlapRecovery
+
end
+
 
+
thisObject.AddClickable()
+
thisObject.Clickable.OnClick(OnClickFunction)</pre>
+
}}
+
 
+
{{ScriptFunction|float|Height|{get; set;}|The height of the character's capsule.|5=<pre>
+
Space.Host.ExecutingObject.CharacterController.Height = 4</pre>|6=<pre>--the below script will make a slider change a Character Controller Height property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.Height = (slider.Value * 10.0) -- from 0.0 to 10.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|float|MinMoveDistance|{get; set;}|Gets or sets the minimum move distance of the character controller.|5=<pre>Space.Host.ExecutingObject.CharacterController.MinMoveDistance = 3</pre>|6=<pre>--this script will make a slider change a Character Controller Min Move Distance property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.MinMoveDistance= (slider.Value * 10.0) -- from 0.0 to 10.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|float|Radius|{get; set;}|The radius of the character's capsule.|5=<pre>Space.Host.ExecutingObject.CharacterController.Radius = 5</pre>|6=<pre>--this script will make a slider change a Character Controller Radius property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.Radius= (slider.Value * 10.0) -- from 0.0 to 10.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|float|SkinWidth|{get; set;}|The character's collision skin width.|5=<pre>Space.Host.ExecutingObject.CharacterController.SkinWidth = 4</pre>|6=<pre>--this script will make a slider change a Character Controller SkinWidth property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.SkinWidth= (slider.Value * 10.0) -- from 0.0 to 10.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|float|SlopeLimit|{get; set;}|The character controllers slope limit in degrees.|5=<pre>Space.Host.ExecutingObject.CharacterController.SlopeLimit= 2</pre>|6=<pre>--this script will make a slider change a Character Controller Slope Limit property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.SlopeLimit= (slider.Value * 180.0) -- from 0.0 to 180.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|float|StepOffset|{get; set;}|The character controllers step offset in meters.|5=
+
<pre>Space.Host.ExecutingObject.CharacterController.StepOffset= 2</pre>|6=<pre>--this script will make a slider change a Character Controller Step Offset property
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
+
 
+
slider = Space.Host.GetReference("theslider").UISlider
+
ccontroller = Space.Host.GetReference("thecharactercontroller").CharacterController
+
 
+
 
+
OVC = function()
+
ccontroller.StepOffset= (slider.Value * 10.0) -- from 0.0 to 10.0
+
end
+
 
+
slider.OnValueChanged(OVC)</pre>
+
}}
+
 
+
{{ScriptFunction|SVector|Velocity|{ get; set; }|The current relative velocity of the Character.|5=
+
function PrintVector (data)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.X)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Y)<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;Space.Log(data.Z)<br>
+
end<br>
+
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
local newVector = Vector.New(5,5,5)<br>
+
local Vectordata = Object.CharacterController.Velocity<br>
+
PrintVector(Vectordata)
+
}}
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 05:32, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/scharactercontroller