Prefab for VRChat worlds to allow for player interactions with world colliders that are scaled relative to your avatar size. PC and Quest compatible. Future support planned for height specific scaling when crouching/going prone.
When playing VRChat, your player's physical collider is always the same size regardless of your avatar's size or the scale it's set to. While this helps maintain a consistent user experience, it comes at the cost of immersion, and limits the kinds of worlds creators can make. Want to experience an Alice in Wonderland type world where you might get scaled down and able to run into a mouse hole or under a bed, or scaled up and able to step over buildings? While there are some present solutions such as selectively disabling colliders (tedious), scaling up or down the world (requires all player at the same scale or else positional desync occurs), or the use of stations (complex and with their own set of issues).
Given the options, I decided to add another to the mix that doesn't use any stations, works independently on each user without requiring synchronization, and works in a simple drop-in prefab capacity. Simply install the package, include the prefab in your hierarchy, specify a parent world object, configure any other values, and it should work.
The result is the scale set on the player should match their collisions with the world. Optional features also included are the ability to scale the player movement/physics to their size, scale their volume, control manual scaling and min/max sizes, enabling/disabling the system altogether, switching out the scalable world parent, etc.
You can see the system in action in the world Scalable Avatar Collider Demo
Add to VRChat Creator Companion
Alternatively, go to Releases on the right and download the latest the zip or unitypackage.
Scaled Collider System
prefab to your project hierarchy. The prefab can be found under Packages/com.prismic247.scaledcolliders
.World Parent
object on the prefab. This is a game object which contains the world colliders you want scaled. DO NOT include the world descriptor, scripts, etc, since this can cause some performance issues such as frame drops, logic running twice, etc. Ensure any colliders you intend to use aren't set to Static. In practice and for performance reasons, try to limit it to objects with colliders that the players will interact with and move around. An enclosed room can likely exclude the floor or ceiling for example, there's no need to scale video players and canvases, etc.Manual Scaling Allowed
and/or Enable Scaled Movement
is enabled, it's recommended that you disable the Udon Behavior on the VRCWorld
that controls avatar scaling and player movement respectively, as these should override those anyways.Show Collider Ghosts
allows for debugging the invisible colliders to see how things work/line up. A ColliderGhost
material is provided, but you can always use your own as well.using Prismic247.ScaledColliders;
in your own Udon# script, creating a public ScaledColliderSystem scaledColliderSystem;
on your UdonSharpBehavior, and setting the value in the inspector to the prefab. Alongside the properties, see the Udon# Public API section below for other functions you can utilize in your own scripts.World Parent
and its children, stripping out the unnecessary elements, and scaling and repositioning the clone inversely to the player. The original world parent has its colliders disabled for local player collision as well. This is how the system functions at its core, but it's not without its issues:
World Parent
(such as doors, removed walls, etc) won't work as normally intended since the clone doesn't have any connection to the original, meaning something like a door that disables to let you through won't have an effect, so try to keep toggles colliders out of the world parent hierarchy if you can help it. One workaround is to reinitialize the scaled colliders after the collider is toggled, such that a new copy of the world parent is created. This can be done either by toggling the ToggleScaledColliders(state)
function off and on, or by calling InitializeScaledColliders()
to reset it.Alongside the configurable properties, the following functions are made available to further control the behavior.
Returns the local player's scale relative to the base eye height. Get the inverse of this value for the local world scale (1 / GetLocalPlayerScale()).
Returns a given player's scale relative to the base eye height. Get the inverse of this value for the player's world scale (1 / GetPlayerScale(player)).
Sets the enabledScaledColliders
state, and returns the state afterwards. Certain conditions such as a missing worldParent
may cause this to reject attempts at enabling, hence the return value.
Sets the showColliderGhosts
state, and returns the state afterwards. Enabling this without having a ghostMaterial
set will simple not render the objects, and it will also not work when enabledScaledColliders
is disabled.
This allows you to swap out the worldParent
for a new one, or to reset the current one if the parameter is null. The old parent will automatically be restored to its original state.