wiki.sine.space | sinespace

Difference between revisions of "Scripting/SJointLimits"

From wiki.sine.space
Jump to: navigation, search
Line 3: Line 3:
 
=Static Public Member Functions=
 
=Static Public Member Functions=
  
{{ScriptFunction|SJointLimits|New|(float min, float max, float bounciness, float bounceMinVelocity, float contactDistance);|Creates a new SJoinLimits with the given min, max, bounciness, bounceMinVelocity and contactDistance.||5=<pre>Limits = Space.Host.ExecutingObject.HingeJoint.Limits.New((1,2,3,4,5))</pre>|6=<pre></pre>}}
+
{{ScriptFunction|SJointLimits|New|(float min, float max, float bounciness, float bounceMinVelocity, float contactDistance);|Creates a new SJoinLimits with the given min, max, bounciness, bounceMinVelocity and contactDistance.||5=<pre>Limits = Space.Host.ExecutingObject.HingeJoint.Limits.New((1,2,3,4,5))</pre>|6=<pre>--the below script will make a slider change all Hinge Joint Limits properties to 0 when clicked
 +
--[Add "thehingejoint" reference to the Scripting Runtime component]
 +
thisObject = Space.Host.ExecutingObject
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
function OnClickFunction()
 +
limits = hingejoint.Limits
 +
hingejoint.Limits = limits.New(0,0,0,0,0)
 +
end
 +
 
 +
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
  
  
 
=Public Member Functions=
 
=Public Member Functions=
{{ScriptFunction|string|ToString|();|Returns this SJointLimits's properties as a string||5=<pre>LimitsString = Space.Host.ExecutingObject.HingeJoint.Limits.ToString()</pre>|6=<pre></pre>}}
+
{{ScriptFunction|string|ToString|();|Returns this SJointLimits's properties as a string||5=<pre>LimitsString = Space.Host.ExecutingObject.HingeJoint.Limits.ToString()</pre>|6=<pre>--the below script will make a UI Text element display this GameObjects Hinge Joint Limits' properties
 +
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
 +
thisObject = Space.Host.ExecutingObject
 +
text = Space.Host.GetReference("thetext").UIText
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
function OnUpdateFunction()
 +
limits = hingejoint.Limits
 +
text.Text = limits.ToString()
 +
end
 +
 
 +
 
 +
thisObject.OnUpdate(OnUpdateFunction)</pre>}}
  
  
 
=Properties=
 
=Properties=
  
{{ScriptFunction|float|Min|{ get;set; }|The lower angular limit (in degrees) of the joint.|5=<pre>Space.Host.ExecutingObject.HingeJoint.Limits.Min = 0</pre>|6=<pre></pre>}}
+
{{ScriptFunction|float|Min|{ get;set; }|The lower angular limit (in degrees) of the joint.|5=<pre>LimitsMin = Space.Host.ExecutingObject.HingeJoint.Limits.Min</pre>|6=<pre>--the below script will make a slider change a Hinge Joint Limits Min property
 +
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
 +
 
 +
slider = Space.Host.GetReference("theslider").UISlider
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
OVC = function()
 +
limits = hingejoint.Limits
 +
limits.Min = (slider.Value * 10.0) -- from 0.0 to 10.0
 +
hingejoint.Limits = limits
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
  
 
{{ScriptFunction|float|Max|{ get;set; }|The upper angular limit (in degrees) of the joint.
 
{{ScriptFunction|float|Max|{ get;set; }|The upper angular limit (in degrees) of the joint.
|5=<pre>Max= Space.Host.ExecutingObject.HingeJoint.Limits.Max = 0 </pre>|6=<pre></pre>}}
+
|5=<pre>LimitsMax= Space.Host.ExecutingObject.HingeJoint.Limits.Max </pre>|6=<pre>--the below script will make a slider change a Hinge Joint Limits Max property
 +
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
 +
 
 +
slider = Space.Host.GetReference("theslider").UISlider
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
OVC = function()
 +
limits = hingejoint.Limits
 +
limits.Max = (slider.Value * 10.0) -- from 0.0 to 10.0
 +
hingejoint.Limits = limits
 +
end
 +
 
 +
slider.OnValueChanged(OVC)
 +
</pre>}}
 +
 
 +
{{ScriptFunction|float|Bounciness|{ get;set; }|Determines the size of the bounce when the joint hits it's limit. Also known as restitution.|5=<pre>LimitsBounciness = Space.Host.ExecutingObject.HingeJoint.Limits.Bounciness </pre>|6=<pre>--the below script will make a slider change a Hinge Joint Limits Bounciness property
 +
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
 +
 
 +
slider = Space.Host.GetReference("theslider").UISlider
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
OVC = function()
 +
limits = hingejoint.Limits
 +
limits.Bounciness = (slider.Value * 1.0) -- from 0.0 to 1.0
 +
hingejoint.Limits = limits
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
 +
 
 +
{{ScriptFunction|float|BounceMinVelocity|{ get;set; }|The minimum impact velocity which will cause the joint to bounce.|5=<pre> LimitsBounceMinVelocity = Space.Host.ExecutingObject.HingeJoint.Limits.BounceMinVelocity</pre>|6=<pre>--the below script will make a slider change a Hinge Joint Limits BounceMinVelocity property
 +
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
 +
 
 +
slider = Space.Host.GetReference("theslider").UISlider
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
 +
 
 +
 
 +
OVC = function()
 +
limits = hingejoint.Limits
 +
limits.BounceMinVelocity = (slider.Value * 10.0) -- from 0.0 to 10.0
 +
hingejoint.Limits = limits
 +
end
 +
 
 +
slider.OnValueChanged(OVC)</pre>}}
 +
 
 +
{{ScriptFunction|float|ContactDistance|{ get;set; }|Distance inside the limit value at which the limit will be considered to be active by the solver.|5=<pre>LimitsContactDistance = Space.Host.ExecutingObject.HingeJoint.Limits.ContactDistance</pre>|6=<pre>--the below script will make a slider change a Hinge Joint Limits Contact Distance property
 +
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]
 +
 
 +
slider = Space.Host.GetReference("theslider").UISlider
 +
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint
  
{{ScriptFunction|float|Bounciness|{ get;set; }|Determines the size of the bounce when the joint hits it's limit. Also known as restitution.|5=<pre>Space.Host.ExecutingObject.HingeJoint.Limits.Bounciness = 0</pre>|6=<pre></pre>}}
 
  
{{ScriptFunction|float|BounceMinVelocity|{ get;set; }|The minimum impact velocity which will cause the joint to bounce.|5=<pre> Space.Host.ExecutingObject.HingeJoint.Limits.BounceMinVelocity = 0</pre>|6=<pre></pre>}}
+
OVC = function()
 +
limits = hingejoint.Limits
 +
limits.ContactDistance = (slider.Value * 10.0) -- from 0.0 to 10.0
 +
hingejoint.Limits = limits
 +
end
  
{{ScriptFunction|float|ContactDistance|{ get;set; }|Distance inside the limit value at which the limit will be considered to be active by the solver.|5=<pre>Space.Host.ExecutingObject.HingeJoint.Limits.ContactDistance= 0</pre>|6=<pre></pre>}}
+
slider.OnValueChanged(OVC)</pre>}}
  
 
{{Scripting Navbox}}
 
{{Scripting Navbox}}

Revision as of 13:47, 15 January 2022


Static Public Member Functions

New

SJointLimits New (float min, float max, float bounciness, float bounceMinVelocity, float contactDistance);

Creates a new SJoinLimits with the given min, max, bounciness, bounceMinVelocity and contactDistance.

Limits = Space.Host.ExecutingObject.HingeJoint.Limits.New((1,2,3,4,5))


--the below script will make a slider change all Hinge Joint Limits properties to 0 when clicked
--[Add "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


function OnClickFunction() 
limits = hingejoint.Limits
hingejoint.Limits = limits.New(0,0,0,0,0)
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)


Public Member Functions

ToString

string ToString ();

Returns this SJointLimits's properties as a string

LimitsString = Space.Host.ExecutingObject.HingeJoint.Limits.ToString()


--the below script will make a UI Text element display this GameObjects Hinge Joint Limits' properties
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
thisObject = Space.Host.ExecutingObject
text = Space.Host.GetReference("thetext").UIText
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


function OnUpdateFunction()
limits = hingejoint.Limits
text.Text = limits.ToString()
end


thisObject.OnUpdate(OnUpdateFunction)


Properties

Min

float Min { get;set; }

The lower angular limit (in degrees) of the joint.

LimitsMin = Space.Host.ExecutingObject.HingeJoint.Limits.Min


--the below script will make a slider change a Hinge Joint Limits Min property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]

slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
limits = hingejoint.Limits
limits.Min = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end

slider.OnValueChanged(OVC)

Max

float Max { get;set; }

The upper angular limit (in degrees) of the joint.


LimitsMax= Space.Host.ExecutingObject.HingeJoint.Limits.Max 


--the below script will make a slider change a Hinge Joint Limits Max property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]

slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
limits = hingejoint.Limits
limits.Max = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end

slider.OnValueChanged(OVC)

Bounciness

float Bounciness { get;set; }

Determines the size of the bounce when the joint hits it's limit. Also known as restitution.

LimitsBounciness = Space.Host.ExecutingObject.HingeJoint.Limits.Bounciness 


--the below script will make a slider change a Hinge Joint Limits Bounciness property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]

slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
limits = hingejoint.Limits
limits.Bounciness = (slider.Value * 1.0) -- from 0.0 to 1.0
hingejoint.Limits = limits
end

slider.OnValueChanged(OVC)

BounceMinVelocity

float BounceMinVelocity { get;set; }

The minimum impact velocity which will cause the joint to bounce.

 LimitsBounceMinVelocity = Space.Host.ExecutingObject.HingeJoint.Limits.BounceMinVelocity


--the below script will make a slider change a Hinge Joint Limits BounceMinVelocity property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]

slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
limits = hingejoint.Limits
limits.BounceMinVelocity = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end

slider.OnValueChanged(OVC)

ContactDistance

float ContactDistance { get;set; }

Distance inside the limit value at which the limit will be considered to be active by the solver.

LimitsContactDistance = Space.Host.ExecutingObject.HingeJoint.Limits.ContactDistance


--the below script will make a slider change a Hinge Joint Limits Contact Distance property
--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]

slider = Space.Host.GetReference("theslider").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
limits = hingejoint.Limits
limits.ContactDistance = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Limits = limits
end

slider.OnValueChanged(OVC)