#How to raycast 2D colliders through a camera rendering onto a texture?

1 messages · Page 1 of 1 (latest)

shadow trench
#

So I have a camera rendering all objects in the "map" layer onto a texture which is then assigned to a raw image in the UI which will serve as the galaxy map. I want the player to be able to mouse over the stars to activate an animation, and then click on them to select them.
Before I was using OnMouseEnter and OnMouseDown to activate these but now that the camera is rendering onto a texture they no longer work. What would be the best solution for this?

spiral onyx
#

you'll have to figure out where on the texture your mouse is in normalized coordinates, then do a manual raycast with Camera.ViewportPointToRay using those normalized texture coordinates

shadow trench
#

Not sure how to do the first bit but I'll look into it, thanks 🙂

shadow trench
#

Well I got the screen size, the size of the rectTransform, and the orthographic sizes of both cameras and have been fiddling around with the ratios

#

Still quite off lol

spiral onyx
#

the orthographic size of the camera isn't really needed

#

This should get you somewhere

shadow trench
#

Oh damn

#

tyvm

shadow trench
#

😮

#

got it working I think

#

yep