- Home /
How to get Vector3.Reflect to make any number of reflections?
So heres my C# script, functions mostly how i need it to but it only works for one reflection. Assumedly i need to write a separate void function that runs every time a new hit is detected but I am having trouble getting my head around how to do that. Any help much appreciated, thanks! void Update () { Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition); Debug.DrawRay(ray.origin, ray.direction * 10000, Color.red); RaycastHit rayHit = new RaycastHit(); Vector3 reflecDir = Vector3.Reflect( ray.direction,Vector3.forward); if (Physics.Raycast( ray, out rayHit, 10000f)) { Debug.DrawRay(rayHit.point, reflecDir * 10000, Color.green); } }
Your question is puzzling. Each input vector and normal combination has one unique output. So for multiple reflections, you will need repeatedly call the function with different inputs and/or normals. You don't define what different inputs you want.