Help colliding HTC Vive controllers.

Unity Developers,

I am currently developing a short HTC Vive game for my EPQ (extended project qualification) in which I am basically recreating the BBC game show of “Hole in the wall”. I’ve finished the basics (added the Steam VR files ect.) and animated a wall with a hole in to move towards the playspace, but my problem now is getting the player to collide with the moving wall. I have never tried to create a game before, and I’m trying to avoid coding whenever possible but any help at all would be greatly appericiated. All I want is for if the controllers or the head of the player collides with the moving wall then it’s game over or to change the value of a points system. The idea is that if they pass through the hole then they gain a point, if they don’t pass through then they lose.

If needed I can upload the Unity files here so you can get a better look.

Thanks!

You can use the InputTracking class to get position/rotation information for any tracked object. My first thought here would be to create some simple game objects that have small sphere colliders with scripts to update their position based on the hand they represent. Then add a similar collider to the camera (for the head). If the wall hits the colliders then you know the player didn’t fit through.

1 Like

So how exactly would I code that? I imagine I use “InputTracking.GetLocalPosition(LeftHand)” but I’ve never written code before so I’m not sure on how I should go about doing this.

I would use the colliders instead:

  1. Add sphere colliders to the controllers and head, scale as necessary
  2. Create a tag and assign it to the controllers and head gameobjects that the sphere colliders are attached to.
  3. Add a script to the moving wall(s) that checks OnCollisionEnter(Collider collider) and in that checks for that which collided’s tag.
    a) if (collider.tag == “controllerorhead”) { // head or collider touched the moving wall, player loses }

Okay, that makes sense. So I should set the controllers to be parents of game objects and use those colliders? Or can I apply a collider directly to the controller?

Also, I noticed that the mesh collider I applied to my Blender made wall will only act as a trigger when the collider is set to “convex” I think? But this stopped me from passing objects through the hole. Is there a way around this?

Don’t move anything under the [CameraRig], do the following to add the collider:
Select the controller->Add Component->Sphere Collider

Convex causes the collider to reform itself without any inward curves (concave). This is more than likely cover the whole causing it to collide.

You can:

  1. Break the model into pieces so the hole is maintained when adding mesh colliders
  2. Use non-mesh colliders to approximate the collidable wall areas, similar to above but you don’t have to break the model up, or
  3. Uncheck Convex, and only use non-mesh colliders on the head and controllers (which sphere collider is) (not sure about this one, read the docs on MeshCollider as there are limitations)

Awesome, I’ll give those a try. Thanks very much :slight_smile: