public override void Awake() { if (collider != null) { collider.CheckDropAxis(); body = collider.connectedBody; if (body == null) { body = Physics.AddBody(); body.Position = VectorConverter.Convert(transform.position, collider.to2dMode); body.Rotation = MathHelper.ToRadians(VectorConverter.Angle(transform.rotation.eulerAngles, collider.to2dMode)); body.UserData = collider; collider.AddCollider(body, mass); } body.BodyType = (isKinematic) ? BodyType.Kinematic : BodyType.Dynamic; body.Enabled = gameObject.active; body.LinearDamping = drag; body.AngularDamping = angularDrag; body.FixedRotation = freezeRotation; RescaleMass(); if (!isKinematic) { Physics.AddRigidBody(body); } } else { #if DEBUG Debug.LogWarning("No collider set on this rigid body " + ToString()); #endif } }
public override void Awake() { if (rigidbody == null) { CheckDropAxis(); connectedBody = Physics.AddBody(); connectedBody.Position = VectorConverter.Convert(transform.position, to2dMode); connectedBody.Rotation = MathHelper.ToRadians(VectorConverter.Angle(transform.rotation.eulerAngles, to2dMode)); connectedBody.UserData = this; connectedBody.BodyType = BodyType.Static; AddCollider(connectedBody, 1); } }