asfenplaza.blogg.se

Unity raycast
Unity raycast













unity raycast

I don't know how to use vector3.reflect ("It seems like Vector3.Reflect is the key but I can't quite figure out how to use it properly.").Now I just have to figure out how to connect the Line Renderer to it and we are in business! Gizmos.DrawLine(startingPosition, position) ĭebug.DrawLine(startingPosition, position, Color.blue) ĭrawReflectionPattern(position, direction, reflectionsRemaining - 1) If (Physics.Raycast(ray, out hit, maxStepDistance))ĭirection = Vector3.Reflect(direction, hit.normal) Private void DrawReflectionPattern(Vector3 position, Vector3 direction, int reflectionsRemaining) Here is what it looks like: public int maxReflectionCount = 5 ĭrawReflectionPattern( + * 0.75f,, maxReflectionCount) Ok so I got the Raycasting Reflection working.and its glorious. Debug.DrawLine(startingPosition, position, Color.blue) Position += reflDirection * maxStepDistance ĭebug.DrawRay(startingPosition, reflDirection, een, 1) ReflDirection = Vector3.Reflect(direction, hit2.normal) lr.SetPosition(1, new Vector3(0, 0, hit.distance)) I still cant get it working properly, but here is what it currently looks like. So I have removed all the Line Renderer stuff because I can worry about that later and I been working on what Hacky suggested. Any ideas on how I might get this working? I really just want to use it to show what angles things will bounce around at. I have even tried to use the Debug.DrawRay but to no avail. I have gotten it to sort of work with Gizmosīut I cant use Gizmos in the real thing and I am having trouble getting it to work with the LineRenderer. It seems like Vector3.Reflect is the key but I can't quite figure out how to use it properly. Reflect(position, direction, reflectionsRemaining - 1) If (Physics.Raycast(ray, out hit2, maxStepDistance))ĭirection = Vector3.Reflect(direction, hit2.normal) ĭebug.DrawRay(startingPosition, position, een) Private void Reflect(Vector3 position, Vector3 direction, int reflectionsRemaining) Reflect( + * 0.75f,, maxReflectionCount) Lr.SetPosition(1, new Vector3(0, 0, hit.distance)) If (Physics.Raycast(transform.position, transform.forward, out hit))

unity raycast

What I am trying to do is fairly straight forward, I am trying to display a Line Renderer that follows my bouncing/reflecting Raycast.















Unity raycast