- Home /
The Child Is Not Hovered When Passing The Parent's Collider
I want to click a child using the MRTK toolkit. The Sphere Object is the child of the Cube Object. Both parent and child are interactable have and colliders.
Using the controller ray, I was able to hit the child, but the child is not hovered nor clicked. I used passing the parent collider with
hit.collider.transform
, changing camera event mask with
GameObject.Find("Main Camera").GetComponent().eventMask = layer_mask;
, and hitting sphere layer mask with
Physics.Raycast(startPoint, endPoint, out hit, layer_mask)
, but non helped to click the sphere :(. The code is as follow:
foreach (var source in MixedRealityToolkit.InputSystem.DetectedInputSources) {
foreach (var p in source.Pointers){// Sould be the controller rayif (p.Result != null && p.PointerName =="DefaultControllerPointer(Clone)"){var startPoint = p.Position;var endPoint = p.Result.Details.Point;var hitObject = p.Result.Details.Object;if (hitObject != null){RaycastHit[] hits = Physics.RaycastAll(startPoint,endPoint, Mathf.Infinity);for (int i = 0; i < hits.Length; i++){RaycastHit hit = hits[i];if (hit.collider.transform.name == "Sphere"){Debug.Log("this is printed");int layer_mask =LayerMask.GetMask("Sphere");GameObject.Find("Main Camera").GetComponent().eventMask= layer_mask;if (Physics.Raycast(startPoint, endPoint, out hit, layer_mask)){Debug.Log("this is printed as well");}}}}}}
When the controller is inside the cube and pass its collider, the sphere (child) is hovered as follow: ![hovered][1]
But when the ray is out of the cube, the sphere is not hoverred, although it is hit. the image is as followed: ![not hovered][2]
BTW. The sphere has the pointer handler.
What is the problem? [1]: https://i.stack.imgur.com/05eEn.jpg [2]: https://i.stack.imgur.com/PaamT.jpg
I know that the problem is definitely for the parent collider. Because when I disable parent collider, the hovering works
Your answer