Polygonal Mind
  • Home
  • Metaverse Builder
  • CryptoAvatars
  • MegaCube
  • Blog
  • Decentraland
  • Projects
  • Assets

Blog

Optimizing VRChat Worlds: Collision Debugging

3/2/2021

0 Comments

 
Premise
VRChat is a well known social platform for all those who have VR equipment, and even if you don't have any specific hardware, you can join the party from your standard PC screen too! When you create a scenario, you have to be cautious with texture sizing and data management to make sure you can run your scene, but also the target audience can too! If you fail to democratize hardware requirements then you fail to create a popular VRChat World.

The mission
Resources
This guide focuses on the Physics Debugger function of Unity and how to set up your 3D Colliders in scene and how to manage triggers in VRChat.

Having a simple colliding set up will help calculations on low-end machines as the physics interactions will be lower and simpler.
  • Unity Editor (2018.4.20f1)
  • VRChat SDK2
Please note that this is VRChat focused but is something Unity Engine related issue.
​
When this article was written, we did not have yet our hands on VRChat SDK3 UDON system and this is mainly written for VRChat SDK2 and Unity General Knowledge.
Optimize VRChat worlds Collision Debugging tutorial guide
​What are Colliders

Collider components define the shape of a GameObject for the purposes of physical collisions. A collider, which is invisible, does not need to be the exact same shape as the same Object’s mesh.

Every time you get yourself into a game, the player moves or you have "physical" interactions with the environment such as dropping a glass or throwing a rock collisions are getting in to work and behaving as solids, triggers or gravity affected objects.

This sorcery works under default parameters but as in every game-engine you can set up colliders at your liking to match your desired interaction results. This definition could be applied to being able to walk on the firm ground but sink progressively as you go into muddy dirt or enter a flowing river.

​Colliders are basically interactions between objects that send messages to the engine to determinate if the object is colliding, and therefore can't proceed to go through it; or its triggering and then it can enter the other collider volume and (if set so) send an specific message.
​
colliders essentials in video games
​Here we could state that the player is walking along the map and decides to enter the river, this literal information could translate into colliders design in a way that define at which height the player is walking on and triggers that are modifying the player speed and turn it slower as it goes further into the river. This does indeed happen in our Avatar Garden environment:
colliders essentials in video games
​As the player will walk through the river, they will pass through the water mesh walking over the river soil instead
Types of Colliders

The three types of Collider interactions present in Unity are Static, Rigidbody and Kinematic.

Each has an specific use, for example Static colliders are for GameObjects that are not meant to move or are not affected by the Gravity. Rigidbody Colliders are meant to be for objects that have "forces" applied on them and therefore gravity (and other possible set up forces) affects them in each frame (unless they are in sleeping mode). Last but not least there are Kinematic Colliders meant to be for Kinematic bodies and are not driven by the physics engine, read more about kinematics here.
​
Colliders shapes in video games
​If we recreate this mockup in Unity and press Play, the engine will make the ball fall and the rock won't move.
​
To apply a 3D Collider component into an object, we have different options at our disposal:
​
  • Box Collider: The simplest and most used type of collider, a bounding box that creates a collision volume around the mesh. Is suitable for almost any type of collider interaction and is perfect for Trigger Volumes.​
Unity Colliders: Box collider
  • Sphere Collider: Perfect for round or almost spherical objects that have to roll or you want to keep that curvature collision without using a Mesh Collider.​
Unity Colliders: Sphere collider
  • ​Capsule Collider: For Cylinder objects, is like an -extruded from the middle- sphere and is good for characters and other objects that require roundness but need tall colliders.​
Unity Colliders: Capsule collider
  • ​Wheel Collider: Suitable for Torus-shaped objects like -the name itself says- wheels. Its use is focused to Racing games or vehicles that use wheels. Applies forces on it and makes it easy to configure a vehicle that runs over different types of soil or roads.​
Unity Colliders: Wheel collider
  • ​​Terrain Collider: Acts as Collider based on the data collected from the Terrain GameObject.​
Unity Colliders: Terrain collider
  • ​Mesh Collider: the perfect option for non-primitive shapes that require complex collision. The best quick workaround to make them simpler and better for the engine is to check the "Convex" toggle box that reduces the mesh collider to 256 tris max. Also this component comes handy when it comes to custom colliders created by ourselves in our modelling toolkit.​
Unity Colliders: Mesh collider
​By default the Mesh collider will pick the Mesh Filter assigned mesh as the Mesh to represent the Collider.

The Rigidbody component goes apart of the Collider component, giving independency and control over itself and acting as an "addon" for the static collider. It does also state if the interaction of the Collider Is Kinematic or not.
Unity Colliders: Rigidbody
​Applying a Collider to a GameObject is as easy as adding the component in the Inspector Window once you have your GameObject selected. It is located in Component/Physics/ but you can also search for it by using the keyword Collider.
Unity Colliders components
​What does the Physics Debugger

​After we set our colliders into scene, the best way to previsualize and correct colliders prior testing is the Physics debugger.

You will find this window located in Window/Analysis/Physics Debugger
Physics Debugger in Unity
This window will make the colliders overdraw over your meshes like if it was adding a layer of semi-transparent objects with a color that matches a type of Collider. Red for static, Yellow for trigger, Green for rigidbody and Blue for kinematic colliders.
Physics Debugger: Collision geometry
​Here you can check/uncheck to display the Collision Geometry and also you can be able to Mouse Select directly your GameObjects by their Collider Volume.
Physics Debugger in Unity
​This window will drop a couple of features to configure to help us out as much as possible to configure and size the colliders.

You can change the colours to match the best ones for you, change the transparency or set a random to create variation between them.
​
The Physics debugger is going to be your best friend to spot flaws in your physics prior playing or even after noticing errors while testing!
Triggers in VRChat

For anyone experienced enough in game development will know that in Unity to activate a trigger you need a C# script telling the engine what to do when one Collider Triggers another Collider. The Trigger bool in the Collider Components tells the physics engine to let the other colliders go through the triggered. This is not possible in VRChat due to the custom script limitations and so it manages trigger by its Event Handler. Just add the VRC_Trigger Script and the SDK will add the Event Handler.
VRChat trigger in Unity
From this point, programming in VRChat turns visual and no real code is needed. Just to be aware that some stuff changes from place and it turns more "Artist friendly".​
VRChat trigger in Unity
​To add a behaviour as a result of a trigger, just click Add in VRC_Trigger component and start configuring your interactions. There are so many that covering a general use of this Triggers is barely impossible. So yes, the sky is the limit. Just remember that this operations can impact performance badly if they turn out to be expensive to execute.​
Applying Colliders in the Gauguin Avatar Garden (100 Avatars)

Colliders in the Gauguin Avatar Garden by Polygonal Mind are a mix of Box Colliders and Mesh Colliders because we wanted to keep it simple and under our control on some other collider volumes. But that is not a clear reference to understand why is like this.

When you get your hands on colliders, the first question you have to ask yourself is:
Why I'm doing a Collider?
Followed by:
What is going to do my Collider?
VRChat 100 Avatars world
​This two questions are essential to keep your collision complexity as low as possible. As you will want to make the Physics engine as smooth as possible to avoid artifacts in the player collision.
​
Gameplay guides collisions. There is no reason to create a collider for every thing in scene. Instead think on how the player is going to play (or how you intend them to play).​
Collision Complexity in 100 avatars VRChat world
Collision Complexity in 100 avatars VRChat world
​The big box in the back is to avoid players from going out the scene, encaging the player is a good way to free them to climb whatever without thinking of getting to the point of breaking the scene.

Once again, one of the best practices in doing game development but this time on Colliders is doing the work by hand. Don't let the engine do the math for you without telling exactly what's doing. Evaluating the best suitable collider in each occasion will give you tighter control over the process of debugging.​​
Mesh Collider match shape vrchat
For example this tree logs doesn't use a Mesh Collider to correctly match their shape when the collider comes to work, but why? There is no reason to spend a complex collision here when the player will just want to notice that there is a log in their way but nothing else.​
Mesh Collider match shape vrchat
Another example on Collider design goes here, you dont need to create a collider for everything. If we would have decided to create a collider for each small rock, the player would notice little bumps when walking and would be very uncomfortable or at least it wouldn't match the playable vision we had. Instead the ground is a Mesh Collider of the same Ground Mesh and the grass is not collideable neither.
Collider design vrchat
​And the last practical examples we are showing here, I want to point out that our trees in the Avatar Garden have not collisions on the top. Because any player can reach the high tree tops and no primitive collider worked good for the curvature of our model; we decided to create a custom model just to fulfil this Mesh Collider need.
​
Other things that we decided to use Mesh Colliders where Bushes and medium-sized plants. This was because there was no form to use primitive shaped colliders for such shapeless vegetation. We tried to keep as simple as possible the shape of all the Mesh Colliders or activate the "Convex" option to reduce to 256 tris if it was higher.​
Simple Mesh Colliders in a rock

Conclusion

In collision, when it comes to game development, physics, or at least basic physics are the second stage of an environment development so keep them always in mind when building your worlds! They can be a truly game changer on how the experience is felt and enjoyed. Keep it simple but also keep it clever!

You are more than welcome to drop any question or your try-out and results!
Join us: https://discord.gg/UDf9cPy

Additional sources:
https://docs.unity3d.com/2018.4/Documentation/Manual/CollidersOverview.html
https://yhscs.y115.org/program/lessons/unityCollisions.php
https://docs.unity3d.com/2018.4/Documentation/Manual/RigidbodiesOverview.html


Picture
Kourtin
ENVIRONMENT ARTIST
I purr when you're not looking. I'm passionate about environments and all the techie stuff to make them look rad. Learning and improving everyday to be a better hooman.
twitter
0 Comments



Leave a Reply.

    Categories

    All
    Blender
    CryptoAvatars
    Decentraland
    Decentraland En Español
    Maya
    Metaverse
    Mixamo
    Morphite
    Substance Painter
    The Sandbox
    Totally Reliable Delivery Service
    Unity 3D
    Updates
    Vrchat

    Archives

    March 2022
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    October 2020
    August 2020
    July 2020
    June 2020
    May 2020
    April 2020
    March 2020
    February 2020
    December 2019
    October 2019
    September 2019
    August 2019
    June 2019
    May 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2016

    Picture
Home
Projects
Assets

Picture
Crypto
Friendly
Picture

Subscribe to get some 💚 in your inbox once in a while.

Follow us and your visit will never be forgotten!
Picture
Picture
Picture

 © 2015-2022 POLYGONAL MIND LTD. ALL RIGHTS RESERVED.
  • Home
  • Metaverse Builder
  • CryptoAvatars
  • MegaCube
  • Blog
  • Decentraland
  • Projects
  • Assets