How can I have a
Physics.Raycast auto-generate a direction for itself to try to hit a given target through a restricted window of space?
After much work, my problem has slightly morphed into one about mesh colliders: given a (convex) mesh collider, how can I detect all of the points intersecting with the collider? Or, if this can be done easily, can I get one
Vector3 per object that is within the mesh collider?
This is kind of a long question, so I'll try to explain it the best I can:
- I have 3 GameObjects: a source, a target, and a "window". This window sits between the source and target.
- I want the source to make a raycast that points in the direction of the target (not necessarily it's
transform.position, just a direction that will make it hit the target) and this raycast must pass through (collide and continue through) the window GameObject
- I would like to automatically generate this direction for the raycast to follow such that #2 happens
- I would like this algorithm to also recognize if the above is not possible
- As an added item, I would like this raycast to pass through (collide and continue through) any objects that may be in it's way between it and the window
How can I accomplish this?
Thank you for your help in advanced!