/// <summary> /// Initializes the destructible properties. /// </summary> /// <param name="damageAmount">The amount of damage to apply to the hit object.</param> /// <param name="impactForce">The amount of force to apply to the hit object.</param> /// <param name="impactForceFrames">The number of frames to add the force to.</param> /// <param name="impactLayers">The layers that the projectile can impact with.</param> /// <param name="impactStateName">The name of the state to activate upon impact.</param> /// <param name="impactStateDisableTimer">The number of seconds until the impact state is disabled.</param> /// <param name="surfaceImpact">A reference to the Surface Impact triggered when the object hits an object.</param> public void InitializeDestructibleProperties(float damageAmount, float impactForce, int impactForceFrames, LayerMask impactLayers, string impactStateName, float impactStateDisableTimer, SurfaceImpact surfaceImpact) { m_Destroyed = false; m_DamageAmount = damageAmount; m_ImpactForce = impactForce; m_ImpactForceFrames = impactForceFrames; m_ImpactLayers = impactLayers; m_ImpactStateName = impactStateName; m_ImpactStateDisableTimer = impactStateDisableTimer; // The SurfaceImpact may be set directly on the destructible prefab. if (m_SurfaceImpact == null) { m_SurfaceImpact = surfaceImpact; } if (m_TrailRenderer != null) { m_TrailRenderer.Clear(); m_TrailRenderer.enabled = true; } if (m_ParticleSystem != null) { m_ParticleSystem.Play(); } if (m_Collider != null) { m_Collider.enabled = false; } // The object may be reused and was previously stuck to a character. if (m_StickyCharacterLocomotion != null) { m_StickyCharacterLocomotion.RemoveIgnoredCollider(m_Collider); m_StickyCharacterLocomotion = null; } }