C# Class KAS.KASModulePhysicChild

A module for a disconnected object that should be affected by the normal physics.
It's expected the object is somehow related to the part. If part gets destroyed then the physical child get destroyed as well.
Inheritance: PartModule
ファイルを表示 Open project: KospY/KAS Class Usage Examples

Public Methods

Method Description
StartPhysics ( GameObject physicObj, float mass, bool delayPhysics = false ) : void

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.

StopPhysics ( ) : void

Stops physics handling on the object.

Rigidbody on the object gets destroyed.

Private Methods

Method Description
FixedUpdate ( ) : void

Overriden from MonoBehavior.

OnDestroy ( ) : void

Overriden from MonoBehavior.

OnPartPack ( ) : void

Part's message handler.

Temporarily suspends physics handling on the object.

OnPartUnpack ( ) : void

Part's message handler.

Resumes physics handling on the object.

WaitAndPromoteToPhysic ( ) : IEnumerator

Turns rigidbody to a physics object.

The update is delayed till the next fixed update to let game's physics to work. Once updated the physical object is guaranteed to be detached from the parent.

WaitAndUpdateVelocities ( ) : IEnumerator

Aligns position, rotation and velocity of the rigidbody.

The update is delayed till the next fixed update to let game's physics to work.

Method Details

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

StopPhysics() public method

Stops physics handling on the object.
Rigidbody on the object gets destroyed.
public StopPhysics ( ) : void
return void