4
\$\begingroup\$

I am currently working on setting up some world objects for my level editor and am running into a bit of a snag. When I get the hit location from the mouse raycast, I would like to determine what part of the object that the user has hit. I am looking for something that would work for each viewport in my map editor.

I would like to use hit detection change the color of an object when the user mouses over it. For instance, if the user mouses over the x axis (red arrow) it would turn from red to white. It doesn’t have to be pixel perfect but I would like to find a single solution that would work in all viewports.

I was thinking that after I get the hit location, I could transform the hit location to match the inverse of the rotation of the camera and perform the checks from there. I'm skeptical that solution will work though.

Viewports with Gizmos

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Quick questions I would like to know before answering anything: You are rendering a single scene from different cameras, correct? Is there any reason this cannot be an editor specific function of the object receiving the hit from the raycast, i.e. and OnMouseHover event? Do you have any event notification built into your editor? \$\endgroup\$ Mar 23, 2018 at 14:08
  • \$\begingroup\$ Yes, this is a single scene with 4 different cameras. As for ur other question, as of right now I have 0 events like that in the system. \$\endgroup\$
    – Chaz H
    Mar 25, 2018 at 0:43
  • \$\begingroup\$ I think I am going to setup a small bounding box on each axis and check the ray against that instead of the line. Just seems easier and will work \$\endgroup\$
    – Chaz H
    Mar 25, 2018 at 0:45
  • \$\begingroup\$ Or you could represent the axis as a ray and do a ray-ray sweep. \$\endgroup\$ Mar 28, 2018 at 18:00

0

You must log in to answer this question.

Browse other questions tagged .