Breakroom is now Sinewave Campus. Book a meeting

SJointLimits

客户端类型
在此类中ToString
  1. 函数
  2. ToString
  3. New
  4. 属性
  5. Min
  6. Max
  7. Bounciness
  8. BounceMinVelocity
  9. ContactDistance
成员 7
函数ToStringReturns this SJointLimits's properties as a string
函数NewCreates a new SJoinLimits with the given min, max, bounciness, bounceMinVelocity and contactDistance.
属性MinThe lower angular limit (in degrees) of the joint.
属性MaxThe upper angular limit (in degrees) of the joint.
属性BouncinessDetermines the size of the bounce when the joint hits it's limit.
属性BounceMinVelocityThe minimum impact velocity which will cause the joint to bounce.
属性ContactDistanceDistance inside the limit value at which the limit will be considered to be active by the solver.

函数​

ToString​

override string ToString()

Returns this SJointLimits's properties as a string

返回值

string

示例

Lua
LimitsString = Space.Host.ExecutingObject.HingeJoint.Limits.ToString()
Lua
--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)

New​

static 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.

参数

名称类型默认值
minfloat–
maxfloat–
bouncinessfloat–
bounceMinVelocityfloat–
contactDistancefloat–

返回值

SJointLimits

示例

Lua
Limits = Space.Host.ExecutingObject.HingeJoint.Limits.New((1,2,3,4,5))
Lua
--the below script will 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)

属性​

Min​

float Min {get; set; }

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

示例

Lua
LimitsMin = Space.Host.ExecutingObject.HingeJoint.Limits.Min
Lua
--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.

示例

Lua
LimitsMax= Space.Host.ExecutingObject.HingeJoint.Limits.Max
Lua
--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.

示例

Lua
LimitsBounciness = Space.Host.ExecutingObject.HingeJoint.Limits.Bounciness
Lua
--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.

示例

Lua
LimitsBounceMinVelocity = Space.Host.ExecutingObject.HingeJoint.Limits.BounceMinVelocity
Lua
--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.

示例

Lua
LimitsContactDistance = Space.Host.ExecutingObject.HingeJoint.Limits.ContactDistance
Lua
--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)