Breakroom is now Sinewave Campus. Book a meeting

SJointSpring

ClientTypes
Dans cette classeToString
  1. Fonctions
  2. ToString
  3. New
  4. Propriétés
  5. Spring
  6. Damper
  7. TargetPosition
Membres 5
FonctionToStringReturns this SJointSpring's properties as a string
FonctionNewCreates a new SJointSpring with the given spring, damper, targetPosition.
PropriétéSpringThe spring forces used to reach the target position.
PropriétéDamperThe damper force uses to dampen the spring.
PropriétéTargetPositionThe target position the joint attempts to reach.

Fonctions​

ToString​

override string ToString()

Returns this SJointSpring's properties as a string

Valeurs de retour

string

Exemple

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

New​

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

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

Paramètres

NomTypeValeur par défaut
springfloat–
damperfloat–
targetPositionfloat–

Valeurs de retour

SJointSpring

Exemple

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

Propriétés​

SpringLecture seule​

float Spring {get; }

The spring forces used to reach the target position.

Exemple

Lua
SpringSpring= Space.Host.ExecutingObject.HingeJoint.Spring.Spring
Lua
--the below script will make a slider change a Hinge Joint Spring Spring 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()
spring = hingejoint.Spring
spring.Spring = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring= spring
end

slider.OnValueChanged(OVC)

DamperLecture seule​

float Damper {get; }

The damper force uses to dampen the spring.

Exemple

Lua
SpringDamper= Space.Host.ExecutingObject.HingeJoint.Spring.Damper
Lua
--the below script will make a slider change a Hinge Joint Spring Damper 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()
spring = hingejoint.Spring
spring.Damper = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring = spring
end

slider.OnValueChanged(OVC)

TargetPositionLecture seule​

float TargetPosition {get; }

The target position the joint attempts to reach.

Exemple

Lua
SpringTargetPosition = Space.Host.ExecutingObject.HingeJoint.Spring.TargetPosition
Lua
--the below script will make a slider change a Hinge Joint Spring TargetPosition 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()
spring = hingejoint.Spring
spring.TargetPosition = (slider.Value * 10.0) -- from 0.0 to 10.0
hingejoint.Spring = spring
end

slider.OnValueChanged(OVC)