KAS.KASModulePhysicChild.StartPhysics C# (CSharp) Method

StartPhysics() public method

Starts physics handling on the object.
The object is expected to not have rigidbody. The one will be added with the proper mass and velocity settings. Parent transform of the physics object will be set top null, and it will become an idependent object.
public StartPhysics ( GameObject physicObj, float mass, bool delayPhysics = false ) : void
physicObj UnityEngine.GameObject Game object to attach physics to. In normal case it's never a part's /// gameobject.
mass float Mass of the rigidbody.
delayPhysics bool If default or false then new object gets parent's velocity /// immediately. Otherwise, the rigidbody is created as kinematic and velocity is sync'ed in the /// next FixedUpdate() call.
return void
        public void StartPhysics(GameObject physicObj, float mass, bool delayPhysics = false)
        {
            KAS_Shared.DebugLog("StartPhysics(PhysicChild)");
            if (this.physicObj == null) {
              this.physicObj = physicObj;
              physicObjRb = physicObj.AddComponent<Rigidbody>();
              physicObjRb.mass = mass;
              physicObjRb.useGravity = false;
              if (delayPhysics) {
            physicObjRb.isKinematic = true;
            StartCoroutine(WaitAndPromoteToPhysic());
              } else {
            physicObjRb.velocity = part.Rigidbody.velocity;
            physicObjRb.angularVelocity = part.Rigidbody.angularVelocity;
            physicObj.transform.parent = null;
              }
            } else {
              KAS_Shared.DebugWarning("StartPhysics(PhysicChild) Physic already started! Ignore.");
            }
        }