Can anybody tell me why my reflected DrawLine isn’t working when using Vector3.Reflect?
// This c# script is attached to the red particles.
//
Vector3 Direction = transform.TransformDirection(Vector3.forward);
RaycastHit RayHit;
if (Physics.Raycast(transform.position, Direction, out RayHit, 1000, layerMask))
{
newPos = RayHit.point;
reflectionAngle = Vector3.Reflect(newPos, RayHit.normal);
Debug.DrawLine(RayHit.point, reflectionAngle);
//
I have no experience in this, but is it possible you want the negative reflection angle?
It doesnt seem to reflect in the right angle (as in amount of degrees), and it reflects in the opposite direction of what you want. Might be off base here, just spitballin
As know one has anwsered, i will have a stab at it (although i have never used reflect myself).
I think the results you are having are correct. The Scripting Manual states:
// Makes the reflected object appear opposite of the original object,
// mirrored along the z-axis of the world
reflectedObject.position = Vector3.Reflect (originalObject.position, Vector3.right);
From the above code, It seems that the result is a mirror of the direction vector you supply. So for your code, you are passing in the normal, which would be away from the face(ie, pointing towards the bottom right of the image) - so, the mirror of this would be pointing in the direction you are seeing.
Thats how I read the manual… sorry I can’t be any more help.