Skip to content

fix: entering play mode can fail on unity 6 - #876

Merged
bdunderscore merged 1 commit into
mainfrom
play-mode-init
Nov 21, 2026
Merged

bdunderscore merged 1 commit into
mainfrom
play-mode-init

Conversation

@bdunderscore

Copy link
Copy Markdown
Owner

On unity 6, when there's a physbone with a parameter configured and the root animator has an animator controller set, we could throw upon entering play mode with:

IndexOutOfRangeException:_ Index must be between 0 and 527
UnityEngine.Animator.GetParameter (System.Int32 index) (at :0)
VRC.Dynamics.AnimParameterAccessAvatarSDK..ctor (UnityEngine.Animator anim, System.String paramName) (at <131eab479bc94e4db6d9ed671f437736>:0)
VRC.SDK3.Avatars.AvatarDynamicsSetup.PhysBone_OnInitialize (VRC.Dynamics.VRCPhysBoneBase physBone) (at ./Packages/com.vrchat.avatars/Editor/VRCSDK/SDK3A/AvatarDynamicsSetup.cs:165)
VRC.Dynamics.VRCPhysBoneBase.InitParameters () (at <131eab479bc94e4db6d9ed671f437736>:0)
nadena.dev.ndmf.VRChat.ForceReinitPhysBonesHook.OnPreprocessAvatar (UnityEngine.GameObject avatarGameObject) (at ./Packages/nadena.dev.ndmf/Editor/VRChat/ForceReinitPhysBonesHook.cs:33)

It appears that in Unity 6, during this early phase of initialization, the animator will report its parameter count, but fail (throw) upon calling GetParameter. This then causes this exception from the SDK.

In any case however, this InitParameters was unnecessary - the animator is not properly configured in most cases anyway, so this InitParameters is too early. It would need to be called again by the avatar emulator after the playable graph is set up.

@bdunderscore
bdunderscore marked this pull request as ready for review November 21, 2026 02:49
Copilot AI lite review requested due to automatic review settings November 21, 2026 02:49
@bdunderscore
bdunderscore enabled auto-merge (rebase) November 21, 2026 02:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

On unity 6, when there's a physbone with a parameter configured and the root animator has an animator controller set, we could throw upon entering play mode with:

```
IndexOutOfRangeException:_ Index must be between 0 and 527
UnityEngine.Animator.GetParameter (System.Int32 index) (at :0)
VRC.Dynamics.AnimParameterAccessAvatarSDK..ctor (UnityEngine.Animator anim, System.String paramName) (at <131eab479bc94e4db6d9ed671f437736>:0)
VRC.SDK3.Avatars.AvatarDynamicsSetup.PhysBone_OnInitialize (VRC.Dynamics.VRCPhysBoneBase physBone) (at ./Packages/com.vrchat.avatars/Editor/VRCSDK/SDK3A/AvatarDynamicsSetup.cs:165)
VRC.Dynamics.VRCPhysBoneBase.InitParameters () (at <131eab479bc94e4db6d9ed671f437736>:0)
nadena.dev.ndmf.VRChat.ForceReinitPhysBonesHook.OnPreprocessAvatar (UnityEngine.GameObject avatarGameObject) (at ./Packages/nadena.dev.ndmf/Editor/VRChat/ForceReinitPhysBonesHook.cs:33)
```

It appears that in Unity 6, during this early phase of initialization, the animator will report its parameter count, but fail (throw) upon calling GetParameter. This then causes this exception from the SDK.

In any case however, this InitParameters was unnecessary - the animator is not properly configured in most cases anyway, so this InitParameters is too early. It would need to be called again by the avatar emulator after the playable graph is set up.

Fixes: #875
@bdunderscore
bdunderscore merged commit bb2f1ed into main Nov 21, 2026
9 checks passed
@bdunderscore
bdunderscore deleted the play-mode-init branch November 21, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants