wiki.sine.space | sinespace

Difference between revisions of "Scripting/SCharacterController"

From wiki.sine.space
Jump to: navigation, search
(Created page with "=Members= {{ScriptFunction|SVector|ClosestPointOnBounds|(SVector position);|The closest point to the bounding box of the attached collider. This can be used to calculate hit...")
 
Line 58: Line 58:
 
}}
 
}}
  
{{ScriptFunction|float|Height|{get; set;}|The height of the character's capsule.|5=
+
{{ScriptFunction|float|Height|{get; set;}|The height of the character's capsule.|5=<pre>
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
Space.Host.ExecutingObject.CharacterController.Height = 4</pre>|6=<pre>--the below script will make a slider change a Character Controller Height property
local Vectordata = Object.CharacterController.Height<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
Space.Log(Vectordata)
+
 
 +
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=
+
{{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
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
local Vectordata = Object.CharacterController.MinMoveDistance<br>
+
 
Space.Log(Vectordata)
+
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=
+
{{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
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
local Vectordata = Object.CharacterController.Radius<br>
+
 
Space.Log(Vectordata)
+
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=
+
{{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
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
local Vectordata = Object.CharacterController.SkinWidth<br>
+
 
Space.Log(Vectordata)
+
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=
+
{{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
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
local Vectordata = Object.CharacterController.SlopeLimit<br>
+
 
Space.Log(Vectordata)
+
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=
 
{{ScriptFunction|float|StepOffset|{get; set;}|The character controllers step offset in meters.|5=
local Object = Space.Scene.Find("SCRIPT_OBJECT")<br>
+
<pre>Space.Host.ExecutingObject.CharacterController.StepOffset= 2</pre>|6=<pre>--this script will make a slider change a Character Controller Step Offset property
local Vectordata = Object.CharacterController.StepOffset<br>
+
--[Add "theslider" and "thecharactercontroller" to the Object References section in Scripting Runtime component]
Space.Log(Vectordata)
+
 
 +
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>
 
}}
 
}}
  

Revision as of 08:15, 25 January 2022

Members

ClosestPointOnBounds

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.

function PrintVector (data)

    Space.Log(data.X)
    Space.Log(data.Y)
    Space.Log(data.Z)
end
local Object = Space.Scene.Find("SCRIPT_OBJECT")
local newVector = Vector.New(5,5,5)
local Vectordata = Object.CharacterController.ClosestPointOnBounds(newVector)

PrintVector(Vectordata)


ClosestPoint

SVector ClosestPoint (SVector position);

The point on the collider that is closest to the specified location.

function PrintVector (data)

    Space.Log(data.X)
    Space.Log(data.Y)
    Space.Log(data.Z)
end
local Object = Space.Scene.Find("SCRIPT_OBJECT")
local newVector = Vector.New(5,5,5)

local Vectordata = Object.CharacterController.ClosestPoint(newVector)
PrintVector(Vectordata)


SimpleMove

bool SimpleMove (SVector speed)

Moves the character with speed.

local Object = Space.Scene.Find("SCRIPT_OBJECT")

local newVector = Vector.New(100,0,0)
local Vectordata = Object.CharacterController.SimpleMove(newVector)

Space.Log(Vectordata)


Move

int Move (SVector motion)

Moves the character with speed.

local Object = Space.Scene.Find("SCRIPT_OBJECT")

local newVector = Vector.New(100,0,0)
local Vectordata = Object.CharacterController.Move(newVector)

Space.Log(Vectordata)


Properties

Center

SVector Center {get; set;}

Returns Center Vector value of the Character Controller.

local Object = Space.Scene.Find("SCRIPT_OBJECT")
Space.Log(Object.CharacterController.Center.X)


DetectCollisions

bool DetectCollisions {get; set;}

Determines whether other rigid bodies or character controllers collide with this character controller (by default this is always enabled).

local Object = Space.Scene.Find("SCRIPT_OBJECT")

local Vectordata = Object.CharacterController.DetectCollisions

Space.Log(Vectordata)


EnableOverlapRecovery

bool EnableOverlapRecovery {get; set;}

Enables or disables overlap recovery.

local Object = Space.Scene.Find("SCRIPT_OBJECT")

local Vectordata = Object.CharacterController.enableOverlapRecovery

Space.Log(Vectordata)


Height

float Height {get; set;}

The height of the character's capsule.

Space.Host.ExecutingObject.CharacterController.Height = 4


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

MinMoveDistance

float MinMoveDistance {get; set;}

Gets or sets the minimum move distance of the character controller.

Space.Host.ExecutingObject.CharacterController.MinMoveDistance = 3


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

Radius

float Radius {get; set;}

The radius of the character's capsule.

Space.Host.ExecutingObject.CharacterController.Radius = 5


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

SkinWidth

float SkinWidth {get; set;}

The character's collision skin width.

Space.Host.ExecutingObject.CharacterController.SkinWidth = 4


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

SlopeLimit

float SlopeLimit {get; set;}

The character controllers slope limit in degrees.

Space.Host.ExecutingObject.CharacterController.SlopeLimit= 2


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

StepOffset

float StepOffset {get; set;}

The character controllers step offset in meters.

Space.Host.ExecutingObject.CharacterController.StepOffset= 2


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

Velocity

SVector Velocity { get; set; }

The current relative velocity of the Character.

function PrintVector (data)

    Space.Log(data.X)
    Space.Log(data.Y)
    Space.Log(data.Z)
end
local Object = Space.Scene.Find("SCRIPT_OBJECT")
local newVector = Vector.New(5,5,5)
local Vectordata = Object.CharacterController.Velocity

PrintVector(Vectordata)