8 [RequireComponent(typeof(TSCollider2D))]
9 [AddComponentMenu(
"TrueSync/Physics/TSRigidBody2D", 11)]
12 public enum InterpolateMode { None, Interpolate, Extrapolate };
14 [FormerlySerializedAs(
"mass")]
23 if (tsCollider._body != null) {
24 return tsCollider._body.Mass;
33 if (tsCollider._body != null) {
34 tsCollider._body.Mass = value;
40 private bool _useGravity =
true;
64 private bool _isKinematic;
101 if (_tsCollider == null) {
102 _tsCollider = GetComponent<TSCollider2D>();
113 if (_tsTransform == null) {
114 _tsTransform = GetComponent<TSTransform2D>();
136 public void AddForce(TSVector2 force, ForceMode mode) {
137 if (mode == ForceMode.Force) {
139 }
else if (mode == ForceMode.Impulse) {
151 AddForce(force, position, ForceMode.Impulse);
161 if (mode == ForceMode.Force) {
163 }
else if (mode == ForceMode.Impulse) {
TSVector2 position
Position of the body.
void MovePosition(TSVector2 position)
Moves the body to a new position.
FP TSAngularVelocity
Set/get body's angular velocity. (radians/s).
void AddForce(TSVector2 force, TSVector2 position, ForceMode mode)
Applies the provided force in the body.
InterpolateMode interpolation
Interpolation mode that should be used.
void MoveRotation(FP rot)
Rotates the body to a provided rotation.
void AddTorque(TSVector2 torque)
Simulates the provided tourque in the body.
void TSApplyTorque(TSVector2 force)
Applies a torque force to the body.
void AddForce(TSVector2 force)
Applies the provided force in the body.
bool IsBodyInitialized
Returns true if the body was already initialized.
TSVector2 velocity
LinearVelocity of the body.
bool TSAffectedByGravity
If true the body is affected by gravity.
void AddForce(TSVector2 force, TSVector2 position)
Applies the provided force in the body.
bool useGravity
If true it uses gravity force.
FP angularVelocity
AngularVelocity of the body (radians/s).
void AddForce(TSVector2 force, ForceMode mode)
Applies the provided force in the body.
bool freezeZAxis
If true it freezes Z rotation of the RigidBody (it only appears when in 2D Physics).
bool isKinematic
If true it doesn't get influences from external forces.
bool TSIsKinematic
If true the body is managed as kinematic.
Represents a physical 2D rigid body.
Abstract collider for 2D shapes.
IBody2D Body
Returns RigidBody associated to this TSRigidBody.
FP rotation
Orientation of the body.
TSVector2 TSLinearVelocity
Set/get body's linear velocity.
void TSApplyForce(TSVector2 force)
Applies a force to the body's center.
void TSApplyImpulse(TSVector2 force)
Applies a impulse to the body's center.