private void AddCharacterFootTriggers(Transform foot, out CharacterFootTrigger footTrigger) { footTrigger = foot.GetComponent <CharacterFootTrigger>(); if (footTrigger == null) { footTrigger = foot.gameObject.AddComponent <CharacterFootTrigger>(); } }
public void PlayFootFallSound(CharacterFootTrigger sender) { if (m_Controller.Grounded && Time.timeSinceLevelLoad > m_FootstepThreshold && m_SpawnFootprints) { var index = Random.Range(0, footstepClips.Length); var clip = footstepClips[index]; sender.AudioSource.clip = clip; sender.AudioSource.Play(); } }
public void StepOnMesh(CharacterFootTrigger sender) { if (m_Controller.Grounded && Time.timeSinceLevelLoad > m_FootstepThreshold && m_SpawnFootprints) { if (sender.transform.position.y < m_Controller.transform.position.y + 0.1f) { var position = sender.transform.position + m_Controller.transform.up * 0.02f; var fwdDirection = Vector3.Cross(m_Transform.right, m_Controller.GroundHit.normal); var rotation = Quaternion.LookRotation(fwdDirection, m_Controller.GroundHit.normal); ObjectPool.Get(m_Decal, position, rotation); PlayFootFallSound(sender); } m_FootstepThreshold = Time.timeSinceLevelLoad + m_FootstepTimer; m_currentStep = sender.transform; } }