wiki.sine.space | sinespace

Difference between revisions of "Scripting/SRigidbody"

From wiki.sine.space
Jump to: navigation, search
(Started the Rigidbody page, adding the description and first 4 properties (Angular Drag, Angular Velocity, Center Of Mass, Drag).)
 
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/srigidbody")
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The Rigidbody class works with the physics of the object. Requires the Rigidbody component to function.
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/srigidbody
 
+
==Properties==
+
 
+
{{ScriptFunction|float|AngularDrag|{ get; set; }|The angular drag of the object.|5=
+
 
+
local obj = Space.Host.ExecutingObject;<br><br>
+
''-- Set a new angular drag value''<br>
+
obj.Rigidbody.AngularDrag = 0.20;<br><br>
+
''-- Get the current angular drag value''<br>
+
Space.Log(obj.Rigidbody.AngularDrag);<br>
+
''-- prints "0.200000..." to the console''}}
+
 
+
 
+
{{ScriptFunction|SVector|AngularVelocity |{ get; set; }|The angular velocity vector of the rigidbody (in radians per second).|5=
+
 
+
local obj = Space.Host.ExecutingObject;<br><br>
+
''-- Set a new angular velocity value''<br>
+
obj.Rigidbody.AngularVelocity = Vector.New(0,Space.Math.Pi,0);<br>
+
''-- Now the object rotates about the Y axis at a speed of 180 degrees per second''<br>
+
''-- (or 30 revolutions per minute)''<br><br>
+
''-- Get the current angular velocity value''<br>
+
Space.Log(obj.Rigidbody.AngularVelocity);<br>
+
''-- prints "[0, 3.141593, 0]" to the console''}}
+
 
+
 
+
{{ScriptFunction|SVector|CenterOfMass |{ get; set; }|The center of mass relative to the local origin.|5=
+
 
+
local obj = Space.Host.ExecutingObject;<br><br>
+
''-- Set a new center of mass''<br>
+
obj.Rigidbody.CenterOfMass = Vector.New(1,0,0);<br>
+
''-- Now the object's center of mass has been moved by 1 at the X axis''<br><br>
+
''-- Get the current center of mass''<br>
+
Space.Log(obj.Rigidbody.CenterOfMass);<br>
+
''-- prints "[1, 0, 0]" to the console''}}
+
 
+
 
+
{{ScriptFunction|float|Drag |{ get; set; }|The drag of the object.|5=
+
 
+
local obj = Space.Host.ExecutingObject;<br><br>
+
''-- Set a new drag value''<br>
+
obj.Rigidbody.Drag = 20;<br>
+
''-- Now the object's drag is set to 20 - the higher the number, the more it is resistant to gravity''<br><br>
+
''-- Get the current drag value''<br>
+
Space.Log(obj.Rigidbody.Drag);<br>
+
''-- prints "20" to the console''}}
+

Latest revision as of 06:20, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/srigidbody