Adjusting speed and foot effects when crouched

Fenda

Member
I'm trying to figure out how to turn off (or significantly decrease the volume) of foot effects when in crouched mode. I'd like to slow down player movement speed too. Is this possible with states in the inspector? I couldn't seem to get it to work.
 
You can definitely use the state system for the foot effects and may be able to use it for the speed. You can set the foot step mode of the Character Foot Effects to none and it'll not play any foot effects. If you are not using root motion then the speed is controlled by the motor acceleration of the Ultimate Character Locomotion component. If you are using root motion then you'll need to have varying root motion speeds for your animation.
 
Thanks, Justin. Would it also be possible to completely change the surface sound effect based on if the player is crouched or not? Still trying to wrap my head around the state system.
 
Yes, you could change the Surface Impact while the crouch state is active which will then use a completely different set of Surface Effects.
 
Just revisiting this again. I've got my character set up to use a different set of Surface Effects when the crouch ability state is active. It's using the new set of effects but I set the min/max volume down to 0.1 in the effects and it doesn't seem to have made any difference.

I've basically cloned my normal footsteps surface effects and am trying to make them much quieter when crouched.
 
Greetings, I too am having this issue. The pitch is randomized but the volume never changes. I'm implementing a stealth movement and need the the volume to drop. I could implement my own script but what appears to be intended behaviour in the SurfaceEffects does not seem to work. Unless I'm missing something.
 
It is the default in the demo scene. I just adjusted the Min/Max Volume values of the SurfaceEffects for FootstepsOnTile, FootstepsOnGrass, Dirt, Metal, Sand, Water and Wood. The volume on ORG-toe_R and ORG-toe_L would never change from the default 0.4.

After sniffing around in the AudioManager I noticed the volume value was not being passed all the way down to PlayInternal(...) and maybe PlayAtPositionInternal(...), I don't remember now. So I added it. A value passed < 0f will not adjust the volume at all.

Now it works great though it could be somewhat problematic as the AudioSource volume is always set to the last played SurfaceEffects volume. Requiring all subsequent audio to explicitly set the appropriate volume. In the case of the Footsteps I don't think that is a problem but, my lack of intimacy with UCC could get me in trouble.
 
Hi Justin,

How would you feel about making the Footstep's AudioSource.volume field (of the CharacterFootEffects ecript) public? At the moment it's hard coded to 0.4f. But making this public would allow us to change it dynamically based on states. For example, if the player was in a crouch they could lower the volume to .2

This would be better as we wouldn't need to duplicate all of the sounds for crouch levels.

Nathan
 
If you add an AudioSource to the foot ahead of time then it'll use that AudioSource. The hardcoded values are only for if there is no audio source attached.
 
Is there a way to have a state change control the output level? I wasn't able to find any way to do this - couldn't figure out how to change the surface impact.

Thanks again
 
There is a property so you can change the SurfaceImpact with the state system, but nothing that controls the volume. Right now this will take a custom script.
 
Well, I found a solution, here it is incase it's helpful for others.

Make sure you have three audio sources on each foot and assign them to this script - just duplicate the existing one, or make sure you set the spatial setting to 3D. Then make a new State preset and assign the desired value for Crouch Volume - I set mine to .1


Code:
public class FootAudioState: StateBehavior
{
    public AudioSource foot1;
    public AudioSource foot2;
    public AudioSource foot3;

    [Tooltip("Crouch volume")]
    [SerializeField] protected float m_stepVolume = .4f;
   
    public float crouchVolume { get { return m_stepVolume; } set { m_stepVolume = value; } }

    /// <summary>
    /// Callback when the StateManager has changed the active state on the current object.
    /// </summary>
    public override void StateChange()
    {
        base.StateChange();
        foot1.volume = crouchVolume;
        foot2.volume = crouchVolume;
        foot3.volume = crouchVolume;
    }
}
 
Last edited:
Top