- Home /
Found the reason why ..
Orientate a quad to the ray cast hit.normal
Hi, what I'm trying to do is when the ray cast id fired I want to place a quad with a texture on it at the hit.point so for testing I tried
Instantiate (prefab, hit.point, Quaternion.LookRotation(hit.normal));
So when the ray cast is fired the quad is placed at the hit.point but the quad is always 180 degrees the wrong way to see the texture?
Ummm... The normal of your quad may be pointing in the opposite direction?
Answer by HarshadK · Jun 27, 2014 at 02:13 PM
I just checked it out and found in order to make a quad get oriented in right direction you need to use:
Instantiate (prefab, hit.point, Quaternion.LookRotation(-hit.normal));
Don't know why but flipping the normal direction works for a quad. Might be because how quads work because for other types of objects you need to use the hit.normal
itself.
Look at Griffo's screen shot. It shows that the quad faces negative z. If you look at the other, +z, side, there's nothing -- most materials use a 1-sided shader. I assume this was done so you can place a plane the usual way, with +z being world +z, and be able to see it w/o any rotation needed.
In general, the front of an object could be +y or any odd thing. Some people always use childing to make the front be +z. If not, have to use something like Quat.LookRot(normal)*Quat.Euler(90,0,0)
.