Hey all,
I've been reading about and trying to fix this issue for too long now. Time to ask for help.
I can easily ray from screen down to objects. That works fine. In fact all my googling takes me to solutions for raycasting from screen to objects. I'm trying to do something much simpler.
Object A rays to Object B.
Object A is a sphere. It has the script attached.
Object B is a cube that should become a child of Object A on Ray hit.
The method is called via a button press. (the "else" confirms the button works). x is a simple bool to ensure the processes are swapped per press.
I made a prototype in 3D and it all worked fine. Now I've attached it to an ImageTarget and I'm using the ARCamera, it no longer works. I get no errors or warnings. It's almost like the ray simply isn't happening.
I'd really appreciate any help with this. I've returned to this problem on and off for over a month, with no progress made. If you want any other info feel free to ask. Thanks in advance you lovely lovely people
[CODE]
void GrabandDropTile() { float maxPickingDistance = 100; //cast from selector to the tile below and child it ready for movement if (Physics.Raycast(transform.localPosition, Vector3.up, out hit, maxPickingDistance) && x == false) { hit.transform.parent = selector_Control.transform; raytest.text = "test success" + hit.distance; } else { raytest.text = " else test" + transform.localPosition; } // re cast to the selected tile and return it to child of the Gameholder if (Physics.Raycast(transform.localPosition, -Vector3.up, out hit, maxPickingDistance) && x == true) { hit.transform.parent = gameHolder.transform; print("Found an object - distance: " + hit.distance); }
}
[/CODE]
Really hard to tell whats
Really hard to tell whats going on from your description. Your script implies you have three game objects, are they all parented to the image target? A screen shot of you Hierarchy might help.