(Started the Rigidbody page, adding the description and first 4 properties (Angular Drag, Angular Velocity, Center Of Mass, Drag).) |
(Added 4 more Properties (FreezeRotation, Kinematic, Mass, MaxAngularVelocity) and a Navbox.) |
||
Line 45: | Line 45: | ||
Space.Log(obj.Rigidbody.Drag);<br> | Space.Log(obj.Rigidbody.Drag);<br> | ||
''-- prints "20" to the console''}} | ''-- prints "20" to the console''}} | ||
+ | |||
+ | |||
+ | {{ScriptFunction|bool|FreezeRotation |{ get; set; }|Controls whether physics will have any impact on the rotation of the object.|5= | ||
+ | |||
+ | local obj = Space.Host.ExecutingObject;<br><br> | ||
+ | ''-- Set FreezeRotation to True''<br> | ||
+ | obj.Rigidbody.FreezeRotation = true;<br> | ||
+ | ''-- Now under no circumstances the object's rotation coordinates will change.''<br><br> | ||
+ | ''-- Get the FreezeRotation value (find out if Freeze Rotation is in action)''<br> | ||
+ | Space.Log(obj.Rigidbody.FreezeRotation);<br> | ||
+ | ''-- prints "True" to the console''}} | ||
+ | |||
+ | {{ScriptFunction|bool|Kinematic |{ get; set; }|Controls whether physics will have any impact on the object.|5= | ||
+ | |||
+ | local obj = Space.Host.ExecutingObject;<br><br> | ||
+ | ''-- Set Kinematic to True''<br> | ||
+ | obj.Rigidbody.Kinematic = true;<br> | ||
+ | ''-- Now the object will not be affected by gravity, collisions, or other forces.''<br><br> | ||
+ | ''-- Get the Kinematic value (find out if Kinematic is in action)''<br> | ||
+ | Space.Log(obj.Rigidbody.Kinematic);<br> | ||
+ | ''-- prints "True" to the console''}} | ||
+ | |||
+ | {{ScriptFunction|float|Mass |{ get; set; }|The mass of the rigidbody.|5= | ||
+ | |||
+ | local obj = Space.Host.ExecutingObject;<br><br> | ||
+ | ''-- Set a new mass of the rigidbody''<br> | ||
+ | obj.Rigidbody.Mass = 0.1;<br><br> | ||
+ | ''-- Get the current value of the rigidbody's mass''<br> | ||
+ | Space.Log(obj.Rigidbody.Mass);<br> | ||
+ | ''-- prints "0.1000000..." to the console''}} | ||
+ | |||
+ | {{ScriptFunction|float|MaxAngularVelocity |{ get; set; }|The maximum angular velocity of the rigidbody (7 by default). Can be useful to prevent an object from spinning uncontrollably fast.|5= | ||
+ | |||
+ | local obj = Space.Host.MaxAngularVelocity;<br><br> | ||
+ | ''-- Set a new maximum angular velocity''<br> | ||
+ | obj.Rigidbody.MaxAngularVelocity = 1;<br> | ||
+ | ''-- Now the object, for example, is more resistant to rolling over upon collision with another object.''<br><br> | ||
+ | ''-- Get the current value of the rigidbody's maximum angular velocity''<br> | ||
+ | Space.Log(obj.Rigidbody.MaxAngularVelocity);<br> | ||
+ | ''-- prints "1" to the console''}} | ||
+ | |||
+ | {{Scripting Navbox}} |
The Rigidbody class works with the physics of the object. Requires the Rigidbody component to function.
The angular drag of the object.
-- Set a new angular drag value
obj.Rigidbody.AngularDrag = 0.20;
-- Get the current angular drag value
Space.Log(obj.Rigidbody.AngularDrag);
The angular velocity vector of the rigidbody (in radians per second).
-- Set a new angular velocity value
obj.Rigidbody.AngularVelocity = Vector.New(0,Space.Math.Pi,0);
-- Now the object rotates about the Y axis at a speed of 180 degrees per second
-- (or 30 revolutions per minute)
-- Get the current angular velocity value
Space.Log(obj.Rigidbody.AngularVelocity);
The center of mass relative to the local origin.
-- Set a new center of mass
obj.Rigidbody.CenterOfMass = Vector.New(1,0,0);
-- Now the object's center of mass has been moved by 1 at the X axis
-- Get the current center of mass
Space.Log(obj.Rigidbody.CenterOfMass);
The drag of the object.
-- Set a new drag value
obj.Rigidbody.Drag = 20;
-- Now the object's drag is set to 20 - the higher the number, the more it is resistant to gravity
-- Get the current drag value
Space.Log(obj.Rigidbody.Drag);
Controls whether physics will have any impact on the rotation of the object.
-- Set FreezeRotation to True
obj.Rigidbody.FreezeRotation = true;
-- Now under no circumstances the object's rotation coordinates will change.
-- Get the FreezeRotation value (find out if Freeze Rotation is in action)
Space.Log(obj.Rigidbody.FreezeRotation);
Controls whether physics will have any impact on the object.
-- Set Kinematic to True
obj.Rigidbody.Kinematic = true;
-- Now the object will not be affected by gravity, collisions, or other forces.
-- Get the Kinematic value (find out if Kinematic is in action)
Space.Log(obj.Rigidbody.Kinematic);
The mass of the rigidbody.
-- Set a new mass of the rigidbody
obj.Rigidbody.Mass = 0.1;
-- Get the current value of the rigidbody's mass
Space.Log(obj.Rigidbody.Mass);
The maximum angular velocity of the rigidbody (7 by default). Can be useful to prevent an object from spinning uncontrollably fast.
-- Set a new maximum angular velocity
obj.Rigidbody.MaxAngularVelocity = 1;
-- Now the object, for example, is more resistant to rolling over upon collision with another object.
-- Get the current value of the rigidbody's maximum angular velocity
Space.Log(obj.Rigidbody.MaxAngularVelocity);
|