Skip to main content

Functions: VRChat

info

New additions in V1 are indicated with a light bulb 💡 icon.

These functions are specific to the VRChat Avatars SDK. For more functions, see Destructive workflow.

To use these functions, use the extensions functions in AacVRCExtensions:

  • Add using AnimatorAsCode.V1.VRC; in your class imports.
  • If you use assembly definitions, add the AnimatorAsCodeFramework.V1.VRC assembly reference.

Minimum version

  • Starting from 1.1.0-beta.1, the minimum VRChat version is 3.5.2, as this adds support for VRC_AnimatorPlayAudio.

Animator creation overview

Base (AacFlBase)

Reference VRChat assets (AacVRCExtensions)

  • AacVrcAssetLibrary VrcAssets()
    Return an AacVrcAssetLibrary, which lets you select various assets from VRChat.

Layer (AacFlLayer)

Create VRChat parameters

  • AacAv3 Av3()
    Return an AacAv3 object, letting you select various standard Avatars 3.0 Animator Parameters. Subsequently invoking its functions will create invoked parameters in that layer.

Avatars 3.0 (AacAv3)

Parameters

  • AacFlBoolParameter IsLocal
    Create a Bool parameter in the animator named IsLocal.

  • AacFlEnumIntParameter<Av3Viseme> Viseme
    Create an Int parameter in the animator named Viseme.

  • AacFlEnumIntParameter<Av3Gesture> GestureLeft
    Create an Int parameter in the animator named GestureLeft.

  • AacFlEnumIntParameter<Av3Gesture> GestureRight
    Create an Int parameter in the animator named GestureRight.

  • AacFlFloatParameter GestureLeftWeight
    Create a Float parameter in the animator named GestureLeftWeight.

  • AacFlFloatParameter GestureRightWeight
    Create a Float parameter in the animator named GestureRightWeight.

  • AacFlFloatParameter AngularY
    Create a Float parameter in the animator named AngularY.

  • AacFlFloatParameter VelocityX
    Create a Float parameter in the animator named VelocityX.

  • AacFlFloatParameter VelocityY
    Create a Float parameter in the animator named VelocityY.

  • AacFlFloatParameter VelocityZ
    Create a Float parameter in the animator named VelocityZ.

  • AacFlFloatParameter VelocityMagnitude💡
    Create a Float parameter in the animator named VelocityMagnitude.

  • AacFlFloatParameter Upright
    Create a Float parameter in the animator named Upright.

  • AacFlBoolParameter Grounded
    Create a Bool parameter in the animator named Grounded.

  • AacFlBoolParameter Seated
    Create a Bool parameter in the animator named Seated.

  • AacFlBoolParameter AFK
    Create a Bool parameter in the animator named AFK.

  • AacFlIntParameter TrackingType
    Create an Int parameter in the animator named TrackingType.

  • AacFlIntParameter VRMode
    Create an Int parameter in the animator named VRMode.

  • AacFlBoolParameter MuteSelf
    Create a Bool parameter in the animator named MuteSelf.

  • AacFlBoolParameter InStation
    Create a Bool parameter in the animator named InStation.

  • AacFlFloatParameter Voice
    Create a Float parameter in the animator named Voice.

  • AacFlBoolParameter Earmuffs💡
    Create a Bool parameter in the animator named Earmuffs.

  • AacFlBoolParameter IsOnFriendsList💡
    Create a Bool parameter in the animator named IsOnFriendsList.

  • AacFlBoolParameter ScaleModified💡
    Create a Bool parameter in the animator named ScaleModified.

  • AacFlFloatParameter ScaleFactor💡
    Create a Float parameter in the animator named ScaleFactor.

  • AacFlFloatParameter ScaleFactorInverse💡
    Create a Float parameter in the animator named ScaleFactorInverse.

  • AacFlFloatParameter EyeHeightAsMeters💡
    Create a Float parameter in the animator named EyeHeightAsMeters.

  • AacFlFloatParameter EyeHeightAsPercent💡
    Create a Float parameter in the animator named EyeHeightAsPercent.

Supporting conditions

  • IAacFlCondition ItIsRemote()
    Verify that IsLocal is false. Create a Bool parameter in the animator named IsLocal.

  • IAacFlCondition ItIsLocal()
    Verify that IsLocal is true. Create a Bool parameter in the animator named IsLocal.

Asset Library (AacVrcAssetLibrary)

  • AvatarMask LeftHandAvatarMask()
    Left Hand avatar mask asset.

  • AvatarMask RightHandAvatarMask()
    Right Hand avatar mask asset.

  • AnimationClip ProxyForGesture(AacAv3.Av3Gesture gesture, bool masculine)
    Gesture proxy animation asset. There are two idle animations for the neutral hand, the bool selects one or the other.

State (AacFlState)

Driver state behaviour

tip

Due to how VRCAvatarParameterDriver has evolved over the years, consider using the Driving lambda expression instead.

Local

  • AacFlState DrivingLocally()
    Set the driver to be Local only. Create an Avatar Parameter Driver state behaviour if it does not exist.

Set

  • AacFlState Drives(AacFlIntParameter parameter, int value)
    Drive the Int parameter to value. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState Drives(AacFlFloatParameter parameter, float value)
    Drive the Float parameter to value. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState Drives(AacFlBoolParameter parameter, bool value)
    Drive the Bool parameter to value. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState Drives(AacFlBoolParameterGroup parameters, bool value)
    Drive the Bool parameter to value. Create an Avatar Parameter Driver state behaviour if it does not exist.

Add

  • AacFlState DrivingIncreases(AacFlFloatParameter parameter, float additiveValue)
    Drive the Float parameter, incrementing it by additiveValue. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState DrivingDecreases(AacFlFloatParameter parameter, float positiveValueToDecreaseBy)
    Drive the Float parameter, decreasing it by the amount of positiveValueToDecreaseBy. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState DrivingIncreases(AacFlIntParameter parameter, int additiveValue)
    Drive the Int parameter, incrementing it by additiveValue. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState DrivingDecreases(AacFlIntParameter parameter, int positiveValueToDecreaseBy)
    Drive the Int parameter, decreasing it by the amount of positiveValueToDecreaseBy. Create an Avatar Parameter Driver state behaviour if it does not exist.

Random

  • AacFlState DrivingRandomizesLocally(AacFlFloatParameter parameter, float min, float max)
    Drive the Float parameter value to be random between min and max. Set the driver to be Local only. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState DrivingRandomizesLocally(AacFlIntParameter parameter, int min, int max)
    Drive the Int parameter value to be random between min and max. Set the driver to be Local only. Create an Avatar Parameter Driver state behaviour if it does not exist.

  • AacFlState DrivingRandomizesLocally(AacFlBoolParameter parameter, float chance)
    Drive the Bool parameter value to be random with the specified chance of being true. Set the driver to be Local only. Create an Avatar Parameter Driver state behaviour if it does not exist.

Tracking state behaviours

  • AacFlState PrintsToLogUsingTrackingBehaviour(string value)
    Use an Animator Tracking Control to print logs to the avatar wearer. Create an Animator Tracking Control state behaviour if it does not exist.

  • AacFlState TrackingTracks(TrackingElement element)
    Use an Animator Tracking Control to set the element to be tracking. Create an Animator Tracking Control state behaviour if it does not exist.

  • AacFlState TrackingAnimates(TrackingElement element)
    Use an Animator Tracking Control to set the element to be animating. Create an Animator Tracking Control state behaviour if it does not exist.

  • AacFlState TrackingSets(TrackingElement element, VRC_AnimatorTrackingControl.TrackingType trackingType)
    Use an Animator Tracking Control to set the element to be the value of trackingType. Create an Animator Tracking Control state behaviour if it does not exist.

Locomotion state behaviour

  • AacFlState LocomotionEnabled()
    Enable locomotion. Create an Animator Locomotion Control if it does not exist.

  • AacFlState LocomotionDisabled()
    Disable locomotion. Create an Animator Locomotion Control if it does not exist.

Driver state behaviour as a lambda expression💡

  • AacVRCFlEditAvatarParameterDriver Driving(Action<AacVRCFlEditAvatarParameterDriver> action)💡
    Creates a new VRCAvatarParameterDriver behaviour, and edits it. By default, it is non-local, so it drives even if it's not on the avatar wearer. This always creates a new behaviour even if there are already other VRCAvatarParameterDriver behaviours.

Audio state behaviour as a lambda expression💡

  • AacVRCFlEditAnimatorPlayAudio Audio(AudioSource source, Action<AacVRCFlEditAnimatorPlayAudio> action)💡
    Creates a new VRCAnimatorPlayAudio behaviour, and edits it. If you don't have the AudioSource, use the overload that accepts a string. By default, this behaviour does nothing (everything is set to NeverApply, and does neither stop nor plays anything), unlike a VRCAnimatorPlayAudio that would be created by hand. This always creates a new behaviour even if there are already VRCAnimatorPlayAudio behaviours.

  • AacVRCFlEditAnimatorPlayAudio Audio(string audioSourcePath, Action<AacVRCFlEditAnimatorPlayAudio> action)💡
    Creates a new VRCAnimatorPlayAudio behaviour, and edits it. This overload accepts a path, but if you do have the AudioSource, use the overload that accepts an AudioSource. By default, this behaviour does nothing (everything is set to NeverApply, and does neither stop nor plays anything), unlike a VRCAnimatorPlayAudio that would be created by hand. This always creates a new behaviour even if there are already VRCAnimatorPlayAudio behaviours.

Driver editing (AacVRCFlEditAvatarParameterDriver)💡

Local

  • AacVRCFlEditAvatarParameterDriver Locally()💡
    Set the driver to be Local only.

Set

  • AacVRCFlEditAvatarParameterDriver Sets(AacFlIntParameter parameter, int value)💡
    Drive the Int parameter to value.

  • AacVRCFlEditAvatarParameterDriver Sets(AacFlFloatParameter parameter, float value)💡
    Drive the Float parameter to value.

  • AacVRCFlEditAvatarParameterDriver Sets(AacFlBoolParameter parameter, bool value)💡
    Drive the Bool parameter to value.

  • AacVRCFlEditAvatarParameterDriver Sets(AacFlBoolParameterGroup parameters, bool value)💡
    Drive the Bool parameter to value.

Add

  • AacVRCFlEditAvatarParameterDriver Increases(AacFlFloatParameter parameter, float additiveValue)💡
    Drive the Float parameter, incrementing it by additiveValue.

  • AacVRCFlEditAvatarParameterDriver Decreases(AacFlFloatParameter parameter, float positiveValueToDecreaseBy)💡
    Drive the Float parameter, decreasing it by the amount of positiveValueToDecreaseBy.

  • AacVRCFlEditAvatarParameterDriver Increases(AacFlIntParameter parameter, int additiveValue)💡
    Drive the Int parameter, incrementing it by additiveValue.

  • AacVRCFlEditAvatarParameterDriver Decreases(AacFlIntParameter parameter, int positiveValueToDecreaseBy)💡
    Drive the Int parameter, decreasing it by the amount of positiveValueToDecreaseBy.

Random

  • AacVRCFlEditAvatarParameterDriver Randomizes(AacFlFloatParameter parameter, float min, float max)💡
    Drive the Float parameter value to be random between min and max.

Audio editing (AacVRCFlEditAnimatorPlayAudio)💡

Play and Stop OnEnter

All of these functions affect both the Stop and Play checkboxes when the state is entered. To do neither Stop nor Play, don't call any of those functions.

  • AacVRCFlEditAnimatorPlayAudio ReplaysOnEnter()💡
    Stop, and Play when the state is entered.

  • AacVRCFlEditAnimatorPlayAudio StartsPlayingOnEnter()💡
    Does not stop, and Play when the state is entered.

  • AacVRCFlEditAnimatorPlayAudio ReplaysOnEnterAfterSeconds(float delaySeconds)💡
    Stop, and Play when the state is entered after a delay in seconds.

  • AacVRCFlEditAnimatorPlayAudio StartsPlayingOnEnterAfterSeconds(float delaySeconds)💡
    Does not stop, and Play when the state is entered after a delay in seconds.

  • AacVRCFlEditAnimatorPlayAudio StopsPlayingOnEnter()💡
    Stop, and do not Play when the state is entered.

Play and Stop OnExit

All of these functions affect both the Stop and Play checkboxes when leaving the state. To do neither Stop nor Play, don't call any of those functions.

  • AacVRCFlEditAnimatorPlayAudio ReplaysOnExit()💡
    Stop, and Play when leaving the state.

  • AacVRCFlEditAnimatorPlayAudio StartsPlayingOnExit()💡
    Does not stop, and Play when leaving the state.

  • AacVRCFlEditAnimatorPlayAudio StopsPlayingOnExit()💡
    Stop, and do not Play when leaving the state.

Clips

  • AacVRCFlEditAnimatorPlayAudio SelectsClipIfStopped(VRC_AnimatorPlayAudio.Order order, AudioClip[] clipsWithNulls)💡
    Defines the list of clips and the order they are going to play in, if stopped.
    The list can safely contain null values.
    If you want to use the VRC_AnimatorPlayAudio.Order.Parameter enum value, use the overload that accepts an AacFlIntParameter instead.

  • AacVRCFlEditAnimatorPlayAudio SelectsClip(VRC_AnimatorPlayAudio.Order order, AudioClip[] clipsWithNulls)💡
    Defines the list of clips and the order they are going to play in.
    The list can safely contain null values.
    If you want to use the VRC_AnimatorPlayAudio.Order.Parameter enum value, use the overload that accepts an AacFlIntParameter instead.

  • AacVRCFlEditAnimatorPlayAudio SelectsClipIfStopped(AacFlIntParameter indexParameter, AudioClip[] clipsWithNulls)💡
    Defines the list of clips, which will play using the parameter as an index, if stopped.
    The list can safely contain null values, however, null values will be removed, causing the indices of elements of that list to change, which may or may not be an issue.

  • AacVRCFlEditAnimatorPlayAudio SelectsClip(AacFlIntParameter indexParameter, AudioClip[] clipsWithNulls)💡
    Defines the list of clips, which will play using the parameter as an index.
    The list can safely contain null values, however, null values will be removed, causing the indices of elements of that list to change, which may or may not be an issue.

Loop

  • AacVRCFlEditAnimatorPlayAudio SetsLoopingIfStopped()💡
    Set the audio source as looping if stopped.

  • AacVRCFlEditAnimatorPlayAudio SetsNonLoopingIfStopped()💡
    Set the audio source as non-looping if stopped.

  • AacVRCFlEditAnimatorPlayAudio SetsLooping()💡
    Set the audio source as looping.

  • AacVRCFlEditAnimatorPlayAudio SetsNonLooping()💡
    Set the audio source as non-looping.

Volume

  • AacVRCFlEditAnimatorPlayAudio RandomizesVolumeIfStopped(float min, float max)💡
    Randomizes the volume if stopped.

  • AacVRCFlEditAnimatorPlayAudio RandomizesVolume(float min, float max)💡
    Randomizes the volume.

  • AacVRCFlEditAnimatorPlayAudio SetsVolumeIfStopped(float value)💡
    Sets the volume if stopped.

  • AacVRCFlEditAnimatorPlayAudio SetsVolume(float value)💡
    Sets the volume.

Pitch

  • AacVRCFlEditAnimatorPlayAudio RandomizesPitchIfStopped(float min, float max)💡
    Randomizes the pitch if stopped.

  • AacVRCFlEditAnimatorPlayAudio RandomizesPitch(float min, float max)💡
    Randomizes the pitch.

  • AacVRCFlEditAnimatorPlayAudio SetsPitchIfStopped(float value)💡
    Sets the pitch if stopped.

  • AacVRCFlEditAnimatorPlayAudio SetsPitch(float value)💡
    Sets the pitch.