Changing AC Footsteps based on Materials and Terrain.
I’m looking for a method to change the Adventure Creators footsteps.
I looked at the method using Physic collider materials via a custom script on also on the wiki - "Sync footstep sounds with collider materials" but that won't work on a Terrain.
I’m looking to do similar, but by detecting the Material the player is standing on rather than a Physic collider, so that I can have footstep sounds groups change when on a listed objects or Terrain material alike. I just haven’t a clue how to do that.
Several First Person Controller’s set ups have this feature, but stuck in with lots of other elements I don’t need and which then conflict with AC, especially when switching between 1st person and Point and Click modes.
I’ve been using the perfectly excellent AC First Person prefab.
Any suggestions on what to do?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Generally Footsteps can be any generic system that you can find because they always play. It's just your character casting a ray and checking the Texture. You only need to integrate it with AC if you want to use the Sound Component, but that could easily be done seperately, too.
This seems to work, just fill out all the fields accordingly. The Index is the order in which you put in your textures in the Terrain Layers, you can just put in the Sounds as they fit in the order:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;
public class AutoSetFootstepTerrain : MonoBehaviour
{
[SerializeField] private Terrain terrain;
[SerializeField] private LayerMask layerMask = new LayerMask();
[SerializeField] private float rayLength = 2f;
[SerializeField] private FootstepTexture[] footstepTextures = new FootstepTexture[0];
[SerializeField] private FootstepMaterial[] footstepMaterials = new FootstepMaterial[0];
}
Improvements to AC's footstep sounds system are certainly on my todo list.
@snan is quite right in that this is a topic that's generic enough to be added onto your game without needing it to directly integrate with AC.
If I understand the Terrain system correctly though, a Terrain uses a single Material with multiple Textures - you'd need to detect the Texture itself rather than the Material you're standing on.
A guide to playing different footsteps with Terrain texture can be found here:
https://johnleonardfrench.com/terrain-footsteps-in-unity-how-to-detect-different-textures/