- Home /
Moving Trigger not detecting stationary MeshCollider
I'm trying to allow a user to select multiple objects by dragging out a selection region with the mouse. The objects are either cubes (using a box collider) or more complex shapes (using a mesh collider). To do this, I'm manipulating a box collider with IsTrigger set to true, which has a RigidBody attached.
The problem I'm having is that the selection box works perfectly for box colliders, but refuses to detect mesh colliders at all.
Things I've tried:
Switching to a non-trigger collider and using OnCollisionEnter
Calling RigidBody.WakeUp() on the selection box every frame
Adding rigidbodies to the mesh colliders, and calling RigidBody.WakeUp() on them every frame
Calling rigidbody.AddForce(Vector3.zero) on the selection box every frame
Making the mesh colliders convex
Changing the rigidbody velocity of the selection box
The only way I can get the mesh to interact with the selection box is if the mesh is actually moving with a rigidbody attached. Obviously I'd rather not have hundreds of static colliders turned into moving colliders with rigidbodies just so I can select them. Any suggestions?
A couple of pics of my setup:
The selection box:
A cube:
A non-cube:
And my physics setup:
In the SelectionPlane, here's the code that repositions the collider:
transform.position = startPos + (currentPos - startPos) / 2f;
transform.Translate(Vector3.up * 1.1f);
transform.localScale = new Vector3(Mathf.Abs(currentPos.x - startPos.x) * ScaleMultiplier, 1f, Mathf.Abs(currentPos.z - startPos.z) * ScaleMultiplier); ;
This is all using Unity 4.6.2f1