Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collision indices #230

Open
ScriptLineStudios opened this issue Dec 31, 2023 · 1 comment
Open

Collision indices #230

ScriptLineStudios opened this issue Dec 31, 2023 · 1 comment

Comments

@ScriptLineStudios
Copy link
Member

I think it would be great to have some sort of mechanism which can tell you which index in an array of colliders your ray interested with. This could, for example be useful in raycasting games perhaps to differentiate between multiple different wall textures or determine if a ray hit a wall or an enemy.

As for how this api could be implemented, there are probably a couple ways to go about it, for example:

raycast(line, colliders) -> ((x, y) | None), (index | None)

Alternatively to avoid modifying existing api, we could introduce something along the lines of raycast_with_index

raycast(line, colliders) -> (x, y) | None
raycast_with_index(line, colliders) -> ((x, y) | None), (index | None)

With either option, the same would be needed for multiraycast.

@itzpr3d4t0r
Copy link
Member

I think this is cool, and I'm leaning a bit more towards adding nothr function rather than modifying the existing one, especially because we could add special arguments as well.
I was thinking we could have an optional argument like index_from that lets you pass a list and returns you the actual object in raycast and a list of objects in multiraycast. I've seen you've suggested this for the single ray raycast, what about the multi one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants