Hello!
I want to "fire" a ray from one set of co-ordinates to another set of co-ordinates and detect whether there is a collision along the length of the ray and if so, where that collision has occurred. The number of objects that could potentially collide with the ray number in the low hundreds.
I know HardonCollider fortunately has the handy "function shape:intersectsRay(x, y, dx, dy)" to test for a collision with a particular shape; my question is: is iterating through all of the potential objects which might collide with the ray the best way of doing this or am I just being an idiot and there's a much better way?
HardonCollider and ray collisions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: HardonCollider and ray collisions
It depends on how you structure your data, if it's just a plain array, then it's probably the only way. Using a tree could speed up the process, but also make the implementation harder, and I'm sure somebody else here will be able to give you another way to store your data that's more efficient, in the end it's just a matter of how much work you do beforehand.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 10 guests