Sponsored By

Keeping VR Physics Fun and Fair for Asymmetrical Multiplayer

How we're handling collisions in BeeBeeQ with Unity, where the VR player can put their hands wherever they want, standard physics collisions don't make sense and as a physics based local asymmetrical multiplayer game it's got to stay fair at all times

Mark Hogan, Blogger

January 16, 2017

4 Min Read

BeeBeeQ is a local asymmetrical multiplayer game where 4 XBox Controller players control a hive of Bees while one VR player controls a tortured Chef, I got an opportunity to take some time to get creative with some VR UX to improve how held objects behave when the VR player puts their hands somewhere they shouldn't, reposted from http://popupasylum.co.uk/?p=1171

It's pretty normal in VR (and any game using a physics engine) to expect that an object acting under gravity will be prevented from intersecting unrealistically with other objects and the virtual environment using physics engine collisions, but in current generation VR the player can put their hands wherever they want, unconstrained by the virtual environment and the behavior of a held object in that circumstance can't really be resolved by the physics engine (without frustration, as shown by the gif below) and is not totally established in the VR industry yet.

The phsics engine disagrees with where your hand is

Getting Inspired

One thing I spotted while playing "I Expect You To Die" (mostly in the office area because in the levels I was too absorbed to do any analysis) was how collisions behaved differently if an object was held, a held object would be allowed to pass through the environment as the hand does, and by setting it up that way the virtual hand and my real hand were always in sync, which just felt so right.


I went through a few iterations to work this into BeeBeeQ which ended up in a neat solution, and now having finished it it feels like it should have been obvious... but this is gamedev, not kicking myself too hard.

So my first thought was just to disable all collisions between the environment and the tool while it's held, basically what  "I Expect You To Die" does (though they disable all collisions, with some extra speed based stuff as described in this far more interesting blog post). This worked for them but in BeeBeeQ this would have allowed the VR player to take a swing at Bee players through walls, in order to keep things fair a held object that's intersecting a wall (or any part of the environment) should not be able to hit the bees.

After experimenting with changing layers in OnCollisionEnter (then not being able to detect OnCollisionExit), then changing the colliders to triggers in OnCollisionEnter and back in OnTriggerExit (OnTriggerExit was not reliably called) I eventually found a solution I feel works.

In Awake of an interactive object I duplicate all the colliders that make it up (we keep colliders and render objects separate so this doesn't result in any extra geometry) and set the duplicates to be triggers. When the object is held the non-trigger colliders are set to a layer that doesn't collide with the environment, triggers still do. In OnTriggerEnter with an environment (static) collider I store the static collider in a list and change the non-trigger colliders layer again to one that doesn't collide with the environment or the bees, then in OnTriggerExit I remove the static collider from the list, and if the list is empty re-enable collisions with the bees. Then finally when the object is dropped I re-enable collisions with the environment.


The flow actually works very well and though I don't like how it needs double colliders I can live with that.

The last thing to do was provide some visual feedback to the VR player to let them know they are performing an illegal move using a ghosting effect, by changing the objects material to a 2 pass Fresnel shader, one pass renders the un-intersected area with ZTest LEqual, the 2nd pass renders the intersected area slightly more transparent with ZTest Greater. This shows the object through the environment but still makes it easy to see where the intersection is happening.

Ghosting effect lets the player know they're intersecting


On a lucky day I get 2 hours to work on BeeBeeQ, this system all happens pretty much automatically without any set up for any new intractable we add which is exactly what I needed.

Whether all this will make it into the final game or not is going to depend on some intensive play testing, but so far I like this behavior a whole lot better than watching the physics engine struggle to maintain order!

Plus it makes it much easier to flip burgers.

Expert level burger flipping

Read more about:


About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like