- Home /
Raycasting on render texture
Rigidbody GetRigidbodyFromMouseClick()
{
RaycastHit hitInfo = new RaycastHit();
Ray ray = targetCamera.ScreenPointToRay(Input.mousePosition);
bool hit = Physics.Raycast(ray, out hitInfo);
if (hit)
{
Ray ray = targetCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
I have a render texture and I'm trying to drag rigidbodies using raycasting but the problem is that it seems to be interfering because when I disable the canvas and render texture it works. I searched for some solutions most notably https://answers.unity.com/questions/411812/raycasting-and-render-texture.html and I tried to replicate what they had but I'm not the best programmer and have no idea if this is correct. I am making the same variable ray which gives me an error but if I try changing the variable name I get no errors but I still can't raycast. I pulling my hair out trying to get this to work but I have no idea. PLEASE help me.
Your answer
Follow this Question
Related Questions
Raycasting depending on viewport 2 Answers
Render Textures and Raycasting 0 Answers
Canvas interaction on render texture to message PhysicsRaycaster 1 Answer
Raycast through render texture from a graphic raycaster? 0 Answers
Two cameras rendering to same viewport rect sometimes causes lower camera to render incorrectly 1 Answer