// Set physics properties void SetPhysics() { // Excluded from sim if (physics.exclude == true) { return; } // MeshCollider physic material preset. Set new or take from parent RFPhysic.SetColliderMaterial(this); // Set physical simulation type. Important. Should after collider material define RFPhysic.SetSimulationType(this); // Do not set convex, mass, drag for static if (simulationType == SimType.Static) { return; } // Convex collider meshCollider. After SetSimulation Type to turn off convex for kinematic RFPhysic.SetColliderConvex(this); // Set density. After collider defined RFPhysic.SetDensity(this); // Set drag properties RFPhysic.SetDrag(this); // Set material solidity and destructible physics.solidity = physics.Solidity; physics.destructible = physics.Destructible; }
// Restore rigid properties static void Reset(RayfireRigid scr) { // Reset caching if it is on scr.meshDemolition.StopRuntimeCaching(); // Reset limitations scr.activation.Reset(); if (scr.restriction != null) { scr.restriction.Reset(); } scr.limitations.Reset(); scr.meshDemolition.Reset(); scr.clusterDemolition.Reset(); scr.fading.Reset(); // Reset damage if (scr.reset.damage == true) { scr.damage.Reset(); } // Set physical simulation type. Important. Should after collider material define RFPhysic.SetSimulationType(scr); }
// Explode kinematik objects void SetKinematic(Projectile projectile) { if (affectKinematic == true && projectile.fade > 0 && projectile.rb.isKinematic == true) { // Convert kinematic to dynamic via rigid script if (projectile.scrRigid != null) { projectile.scrRigid.simulationType = SimType.Dynamic; RFPhysic.SetSimulationType(projectile.scrRigid); // Set convex shape if (projectile.scrRigid.physics.meshCollider is MeshCollider == true) { ((MeshCollider)projectile.scrRigid.physics.meshCollider).convex = true; } } // Convert regular kinematik to dynamic else { projectile.rb.isKinematic = false; // TODO Set mass // Set convex MeshCollider meshCol = projectile.rb.gameObject.GetComponent <MeshCollider>(); if (meshCol != null && meshCol.convex == false) { meshCol.convex = true; } } } }
// Set rigid props void SetRigid() { if (mode == AnimatorType.Play) { List <RayfireRigid> rigidList = gameObject.GetComponentsInChildren <RayfireRigid>().ToList(); foreach (RayfireRigid rigid in rigidList) { if (rigid.physics.exclude == false) { rigid.physics.recorder = true; // Check for kinematic state if (setToKinematic == true) { if (rigid.simulationType != SimType.Static || rigid.simulationType == SimType.Kinematic) { rigid.simulationType = SimType.Kinematic; RFPhysic.SetSimulationType(rigid); } } } } } }