--the below script will make a UI Text element display this GameObjects Hinge Joint Motor properties--[Add "thetext" and "thehingejoint" reference to the Scripting Runtime component]thisObject = Space.Host.ExecutingObjecttext = Space.Host.GetReference("thetext").UITexthingejoint = Space.Host.GetReference("thehingejoint").HingeJointfunctionOnUpdateFunction()motor = hingejoint.Motortext.Text = motor.ToString()endthisObject.OnUpdate(OnUpdateFunction)
New
static SJointMotor New (float targetVelocity, float force, bool freeSpin)
Creates a new SJointMotor with the given targetVelocity, force, freeSpin.
--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.ExecutingObjecthingejoint = Space.Host.GetReference("thehingejoint").HingeJointfunctionOnClickFunction() motor = hingejoint.Motorhingejoint.Motor = motor.New(0,0,false)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClickFunction)
Properties
TargetVelocity
float TargetVelocityget
The motor will apply a force up to force to achieve targetVelocity.
--the below script will make a slider change a Hinge Joint Motor TargetVelocity property--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]slider = Space.Host.GetReference("theslider").UISliderhingejoint = Space.Host.GetReference("thehingejoint").HingeJointOVC=function()motor = hingejoint.Motormotor.TargetVelocity = (slider.Value *10.0) -- from 0.0 to 10.0hingejoint.Motor = motorendslider.OnValueChanged(OVC)
--the below script will make a slider change a Hinge Joint Motor Force property--[Add "theslider" and "thehingejoint" reference to the Scripting Runtime component]slider = Space.Host.GetReference("theslider").UISliderhingejoint = Space.Host.GetReference("thehingejoint").HingeJointOVC=function()motor = hingejoint.Motormotor.Force = (slider.Value *10.0) -- from 0.0 to 10.0hingejoint.Motor = motorendslider.OnValueChanged(OVC)
FreeSpin
bool FreeSpinget
If freeSpin is enabled the motor will only accelerate but never slow down.