public void CheckAndDestroy(Collision collision) { // //Debug.Log(transform.parent.name + " colliding with " + collision.gameObject.name); // TODO: De momento chequeo simple // Quedetecte si es el gusano // Y si lo es se destruye GigaWormBehaviour wormBehaviour = collision.collider.GetComponentInParent <GigaWormBehaviour>(); // if (wormBehaviour != null) { wormBehaviour.ImpactWithTerrain(hardEnough); } // Con kinematicos // Con suerte nos podremos quedar con este Rigidbody colliderRb = collision.rigidbody; if (colliderRb != null) { // Si es kinematico destruir y punto if (colliderRb.isKinematic) { DestroyTerrainElement(); } // Y chequeando fuerza float colliderForce = colliderRb.velocity.magnitude; if (colliderForce > structuralResistance) { DestroyTerrainElement(); } } }
// Start is called before the first frame update void Start() { gigaWormBehaviour = FindObjectOfType <GigaWormBehaviour>(); player = FindObjectOfType <RobotControl>(); playerRb = PlayerReference.playerRb; // asEmissionControl = new ParticleSystem.EmissionModule[acidShowers.Length]; asMainControl = new ParticleSystem.MainModule[acidShowers.Length]; asInitialEmission = new float[acidShowers.Length]; asInitialSpeed = new float[acidShowers.Length]; for (int i = 0; i < asEmissionControl.Length; i++) { asEmissionControl[i] = acidShowers[i].emission; asMainControl[i] = acidShowers[i].main; asInitialEmission[i] = asEmissionControl[i].rateOverTime.constant; asInitialSpeed[i] = asMainControl[i].startSpeed.constant; } }