Breakroom is now Sinewave Campus. Book a meeting

SJointMotor

العميلالأنواع
في هذا الصنفToString
  1. الدوال
  2. ToString
  3. New
  4. الخصائص
  5. TargetVelocity
  6. Force
  7. FreeSpin
الأعضاء 5
دالةToStringReturns this SJointMotor's properties as a string
دالةNewCreates a new SJointMotor with the given targetVelocity, force, freeSpin.
خاصيةTargetVelocityThe motor will apply a force up to force to achieve targetVelocity.
خاصيةForceThe motor will apply a force.
خاصيةFreeSpinIf freeSpin is enabled the motor will only accelerate but never slow down.

الدوال​

ToString​

override string ToString()

Returns this SJointMotor's properties as a string

القيم المرجعة

string

مثال

Lua
MotorString = Space.Host.ExecutingObject.HingeJoint.Motor.ToString()
Lua
--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.ExecutingObject
text = Space.Host.GetReference("thetext").UIText
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


function OnUpdateFunction()
motor = hingejoint.Motor
text.Text = motor.ToString()
end


thisObject.OnUpdate(OnUpdateFunction)

New​

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

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

المعاملات

الاسمالنوعالقيمة الافتراضية
targetVelocityfloat–
forcefloat–
freeSpinbool–

القيم المرجعة

SJointMotor

مثال

Lua
Motor= Space.Host.ExecutingObject.HingeJoint.Motor.New(1,2,true)
Lua
--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)

الخصائص​

TargetVelocityللقراءة فقط​

float TargetVelocity {get; }

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

مثال

Lua
MotorTargetVelocity = Space.Host.ExecutingObject.HingeJoint.Motor.TargetVelocity
Lua
--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").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
motor = hingejoint.Motor
motor.TargetVelocity = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Motor = motor
end

slider.OnValueChanged(OVC)

Forceللقراءة فقط​

float Force {get; }

The motor will apply a force.

مثال

Lua
MotorForce= Space.Host.ExecutingObject.HingeJoint.Motor.Force
Lua
--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").UISlider
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


OVC = function()
motor = hingejoint.Motor
motor.Force = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Motor = motor
end

slider.OnValueChanged(OVC)

FreeSpinللقراءة فقط​

bool FreeSpin {get; }

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

مثال

Lua
MotorFreeSpin = Space.Host.ExecutingObject.HingeJoint.Motor.FreeSpin
Lua
--the below script will toggle Hinge Joint Motor FreeSpin property
--[Add "thehingejoint" reference to the Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject
hingejoint = Space.Host.GetReference("thehingejoint").HingeJoint


function OnClickFunction()
motor = hingejoint.Motor
motor.FreeSpin = not motor.FreeSpin
hingejoint.Motor = motor
end

thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClickFunction)