wiki.sine.space | sinespace

Difference between revisions of "Scripting/SJointMotor"

From wiki.sine.space
Jump to: navigation, search
Line 1: Line 1:
 
=Static Public Member Functions=
 
=Static Public Member Functions=
  
{{ScriptFunction|SJointMotor|New|(float targetVelocity, float force, bool freeSpin);|Creates a new SJointMotor with the given targetVelocity, force, freeSpin.||5=<pre>Motor= Space.Host.ExecutingObject.HingeJoint.Motor.New(1,2,true)</pre>|6=<pre></pre>}}
+
{{ScriptFunction|SJointMotor|New|(float targetVelocity, float force, bool freeSpin);|Creates a new SJointMotor with the given targetVelocity, force, freeSpin.||5=<pre>Motor= Space.Host.ExecutingObject.HingeJoint.Motor.New(1,2,true)</pre>|6=<pre>--the below script will change all Hinge Joint Motor 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()
 +
motor = hingejoint.Motor
 +
hingejoint.Motor = motor.New(0,0,false)
 +
end
 +
 
 +
thisObject.AddClickable()
 +
thisObject.Clickable.OnClick(OnClickFunction)</pre>}}
  
  

Revision as of 14:32, 15 January 2022

Static Public Member Functions

New

SJointMotor New (float targetVelocity, float force, bool freeSpin);

Creates a new SJointMotor with the given targetVelocity, force, freeSpin.

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


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

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


Public Member Functions

ToString

string ToString ();

Returns this SJointMotor's properties as a string

MotorString = Space.Host.ExecutingObject.HingeJoint.Motor.ToString()



Properties

TargetVelocity

float TargetVelocity { get;set; }

The motor will apply a force up to force to achieve targetVelocity.

MotorTargetVelocity = Space.Host.ExecutingObject.HingeJoint.Motor.TargetVelocity


Force

float Force { get;set; }

The motor will apply a force.

MotorForce= Space.Host.ExecutingObject.HingeJoint.Motor.Force 


FreeSpin

bool FreeSpin { get;set; }

If freeSpin is enabled the motor will only accelerate but never slow down.

MotorFreeSpin = Space.Host.ExecutingObject.HingeJoint.Motor.FreeSpin