wiki.sine.space | sinespace

Difference between revisions of "Scripting/SJointSpring"

From wiki.sine.space
Jump to: navigation, search
Line 17: Line 17:
  
 
=Public Member Functions=
 
=Public Member Functions=
{{ScriptFunction|string|ToString|();|Returns this SJointSpring's properties as a string||5=<pre>SpringString = Space.Host.ExecutingObject.HingeJoint.Spring.ToString()</pre>|6=<pre>--the below script will make a UI Text element display this GameObjects Hinge Joint Motor properties
+
{{ScriptFunction|string|ToString|();|Returns this SJointSpring's properties as a string||5=<pre>SpringString = Space.Host.ExecutingObject.HingeJoint.Spring.ToString()</pre>|6=<pre>--the below script will make a UI Text element display this GameObjects Hinge Joint Spring properties
 
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
 
--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]
 
thisObject = Space.Host.ExecutingObject
 
thisObject = Space.Host.ExecutingObject
Line 25: Line 25:
  
 
function OnUpdateFunction()
 
function OnUpdateFunction()
motor = hingejoint.Motor
+
spring = hingejoint.Spring
text.Text = motor.ToString()
+
text.Text = spring.ToString()
 
end
 
end
  

Revision as of 14:39, 15 January 2022

Static Public Member Functions

New

SJointSpring New (float spring, float damper, float targetPosition);

Creates a new SJointSpring with the given spring, damper, targetPosition.

Motor= Space.Host.ExecutingObject.HingeJoint.Spring.New(1,2,3)


--the below script will change all Hinge Joint Spring 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() 
spring = hingejoint.Spring
hingejoint.Spring = spring .New(0,0,0)
end

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


Public Member Functions

ToString

string ToString ();

Returns this SJointSpring's properties as a string

SpringString = Space.Host.ExecutingObject.HingeJoint.Spring.ToString()


--the below script will make a UI Text element display this GameObjects Hinge Joint Spring 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()
spring = hingejoint.Spring
text.Text = spring.ToString()
end


thisObject.OnUpdate(OnUpdateFunction)


Properties

Spring

float Spring { get;set; }

The spring forces used to reach the target position.

SpringSpring= Space.Host.ExecutingObject.HingeJoint.Spring.Spring


Damper

float Damper { get;set; }

The damper force uses to dampen the spring.

SpringDamper= Space.Host.ExecutingObject.HingeJoint.Spring.Damper


TargetPosition

float TargetPosition { get;set; }

The target position the joint attempts to reach.

SpringTargetPosition = Space.Host.ExecutingObject.HingeJoint.Spring.TargetPosition