Forum rules - please read before posting.

Different Footsteps on certain areas of the terrain

Hi all,

I have been struggling with this and maybe you guys can help me.
I followed these instructions https://adventure-creator.fandom.com/wiki/Sync_footstep_sounds_with_collider_materials
My player is walking several different surfaces. But the error I am getting is object reference set to null, although I have added all required fields. Is there any other way so that the player footstep sounds can play on different areas of the map, for example grass, tiles, etc.

Comments

  • edited December 2023

    Can you share the exact message you're getting, stacktrace included, as well as your AC/Unity versions and a shot of the component's Inspector?

  • Hi Chris, thank you for your reply.
    Here is the full error message:

    NullReferenceException: Object reference not set to an instance of an object
    AutoSetFootstepSounds+FootstepMaterial.Apply (AC.FootstepSounds footstepSounds) (at Assets/Scripts/Player/AutoSetFootstepSounds.cs:70)
    AutoSetFootstepSounds.OnStandMaterial (UnityEngine.PhysicMaterial material) (at Assets/Scripts/Player/AutoSetFootstepSounds.cs:52)
    AutoSetFootstepSounds.LateUpdate () (at Assets/Scripts/Player/AutoSetFootstepSounds.cs:33)

    I am currently running Unity 2022.2.10 and AC v1.79.1
    Here is a screenshot of the component assigned to the player.

    I have added all the required Physic Materials to the required floors. All of the floors are on the default layer.

  • edited December 2023

    @gv1351 I'm using the same script, and the only difference i can see, is that i have a "Footstep Sounds" and "Sound" Component on the Object aswell. Could that be the problem?
    I have these on a Child Object of the Player, right at the bottom of the feet.

    • Everything seems to be setup right, you have the physics materials.
    • The Script is on the Player.
    • Is it placed in the feet area/at the bottom of the Player, so raycast can reach the material? Just put in a big ray length value, to see if that's it.

    Just for comparison:
    The Player Inspector for the footsteps:

    What the walkable surface is setup like

  • Thanks @snan I managed to get the player to detect the different terrains, but now for some odd reason the footstep sound does not stop playing and it is looping over each other and** Only play grounded is** checked.

  • edited December 2023

    I've had that problem with animation events, which way of playing sounds are you using?

    But the best thing would be, as Chris said, just posting your whole setup with all the inspectors of the components that are part of the footsteps.

  • @snan the sounds are playing automatically from the sound source. What else do you require because I gave everything that is needed for this to work.

  • The Auto Set Footstep Sounds component merely affects which sounds are played. Playback is still down to your Footstep Sounds component.

    Can you share the Footstep Sounds component Inspector, as well as the expanded Audio Source it's set to affect?

    To pre-empt: if you've got Play sounds set to Via Animation Events, can you also share your character's Animator?

  • Hi @ChrisIceBox thanks for your reply. I will share a couple of images with you.

    Player prefab - SND EFX is where the Audio source, Sound, Footstep sound, and Auto set footsteps sounds components are stored.

    The actual SND EFX component

  • They are set to play automatically, based on the character's movement. Are the AudioClips themselves one step each (i.e. not a long series of step sounds)?

  • The footsteps sound are a basic loop of 4 steps per loop. But I thought that the sound would stop as soon as the player stop moving.

  • It won't, that could cause it to cutoff mid-step.

    Separate them into 4 and assign each separately.

  • Will so thanks Chris.
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.