How to detect match side of object collider?
Hi Everyone,
For my first Unity 3D VR project. I am currently stuck trying to figure out whether the side of the tire iron match with the lugnut head, then the user can twist the tire iron. I have a bounds class method extension that looks like this:
public static class BoundExtension {
public static bool Contains(this Bounds container, Bounds other) {
return container.min.x <= other.min.x
&& container.min.y <= other.min.y
&& container.min.z <= other.min.z
&& container.max.x >= other.max.x
&& container.max.y >= other.max.y
&& container.min.z >= other.min.z;
}
}
I have a collider detection method that looks like this:
public Transform m_NewTransform;
Collider tireIron;
Collider lugNut;
void Start() {
tireIron = GetComponent<Collider>();
lugNut= m_NewTransform.GetComponent<Collider>();
}
void Update() {
if (tireIron.bounds.Contains(lugNut.bounds) ) {
Debug.Log("Bounds contain : " + lugNut);
}
}
This works, which worked for colliders that were aligned defaultly, but it does not respect to rotation of the object. Any concrete examples or any other suggestions that could help me understand how this could work ? I would be happy to learn more.
Your answer
Follow this Question
Related Questions
Mesh collider 0 Answers
Problem with collision 2 Answers
How best to detect when a charcter object cannot move? 3 Answers
Creating solid meshes and turning them into permeable with trigger 0 Answers