Forum rules - please read before posting.

Autodetect footsteps by layer?

Hi

Any chance you could add the ability to autodetect surface type by layer?

I'm looking at a 2d top down adventure using tilemaps. They won't work with physics materials, but the different ground types could have layers or tags assigned ("road", "carpet" etc).

Is that possible?

Comments

  • It can be done via custom script - see the Manual's "Footstep sounds" chapter for details.

    In the Footstep Sounds component, uncheck Auto-detect surface? and then add a custom script that hooks into OnRequestFootstepSounds event, which then reads the current tile's data.

    What data exactly you read would be down to your need/preference - it may be best to use a custom tile that you can assign such data to. However, the code to extract it would be in a script along these lines:

    using UnityEngine;
    using AC;
    
    public class SurfaceDetectorExample : MonoBehaviour
    {
    
        void OnEnable () { EventManager.OnRequestFootstepSounds += OnRequestFootstepSounds; }
        void OnDisable () { EventManager.OnRequestFootstepSounds -= OnRequestFootstepSounds; }
    
        void OnRequestFootstepSounds (FootstepSounds footstepSounds)
        {
            string surfaceName = "Grass"; // For example
            footstepSounds.CurrentSurface = KickStarter.settingsManager.GetSurface (surfaceName);
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.