11 private const float DELTA_TIME_FACTOR = 10f;
16 private TSVector2 _position;
25 if (tsCollider != null && tsCollider.
Body != null) {
34 if (tsCollider != null && tsCollider.
Body != null) {
52 if (tsCollider != null && tsCollider.
Body != null) {
61 if (tsCollider != null && tsCollider.
Body != null) {
86 private bool _serialized;
88 private TSVector2 scaledCenter {
90 if (tsCollider != null) {
94 return TSVector2.zero;
104 private bool initialized =
false;
108 public void Start() {
109 if (!Application.isPlaying) {
114 rb = GetComponent<TSRigidBody2D> ();
125 tsCollider = GetComponent<TSCollider2D>();
126 if (transform.parent != null) {
134 if (tsCollider != null) {
140 StateTracker.AddTracking(
this);
146 public void Update() {
147 if (Application.isPlaying) {
156 private void UpdateEditMode() {
157 if (transform.hasChanged) {
158 _position = transform.position.ToTSVector2();
159 _rotation = transform.rotation.eulerAngles.z;
160 _scale = transform.localScale.ToTSVector();
166 private void UpdatePlayMode() {
169 transform.position = Vector3.Lerp(transform.position,
position.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
170 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 0,
rotation.AsFloat()), Time.deltaTime * DELTA_TIME_FACTOR);
171 transform.localScale = Vector3.Lerp(transform.localScale,
scale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
175 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, 0,
rotation.AsFloat()), Time.deltaTime * DELTA_TIME_FACTOR);
176 transform.localScale = Vector3.Lerp(transform.localScale,
scale.ToVector(), Time.deltaTime * DELTA_TIME_FACTOR);
181 transform.position =
position.ToVector();
183 Quaternion rot = transform.rotation;
184 rot.eulerAngles =
new Vector3(0, 0,
rotation.AsFloat());
185 transform.rotation = rot;
187 transform.localScale =
scale.ToVector();
InterpolateMode interpolation
Interpolation mode that should be used.
bool IsBodyInitialized
Returns true if the body was already initialized.
TSVector2 TSPosition
Set/get body's position.
Represents a physical 2D rigid body.
TSVector2 ScaledCenter
Returns a version of collider's center scaled by parent's transform.
Abstract collider for 2D shapes.
IBody2D Body
Returns RigidBody associated to this TSRigidBody.
TSVector2 TSLinearVelocity
Set/get body's linear velocity.
FP TSOrientation
Set/get body's orientation.