/// <summary> /// Update foot step context to match the sound that should be produced by the /// given ground collider. This works by searching for a FootstepContext /// script attached to the object's hierarchy. /// </summary> public void SetLastGroundObject(Collider collider) { FootstepContext c = collider.transform.GetComponentInParent <FootstepContext>(); if (c != null) { footstepContext = c.type; } else { string colName = collider.name.ToLower(); if (colName.Contains("ice") || colName.Contains("icy")) { footstepContext = FootstepContext.Type.ice; } else { footstepContext = FootstepContext.Type.gravel; } } }
private AudioClip[] GetClipPool(FootstepContext.Type type) { switch (type) { case FootstepContext.Type.solid: return(footstepClips_solid); case FootstepContext.Type.metal: return(footstepClips_metal); case FootstepContext.Type.water: return(footstepClips_water); case FootstepContext.Type.ice: return(footstepClips_ice); case FootstepContext.Type.gravel: return(footstepClips_gravel); case FootstepContext.Type.glass: return(footstepClips_glass); case FootstepContext.Type.brokenGlass: return(footstepClips_brokenGlass); default: Debug.LogError("Encountered unknown footstep context: " + type); return(null); } }
private void Awake() { move = transform.GetComponentInParent <UFPlayerMovement>(); footstepContext = FootstepContext.Type.gravel; }