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

Fix: RayCast3D.get_collider does not return a CollisionShape3D #100394

Closed

Conversation

Akshajk3
Copy link

  • Modified the RayCast3D.get_collider() function to ensure it only returns CollisionObject3D instances.
  • The function now uses Object::cast_to<CollisionObject3D>(object) to perform a safe cast and return null if the object is not of the expected type.
  • This resolves issues where RayCast3D.get_collider() could return objects like CSGShape3D, leading to runtime errors and incorrect behavior.

Fixes: #100139

…2345\)

- Modified the `RayCast3D.get_collider()` function to ensure it only returns `CollisionObject3D` instances.
- The function now uses `Object::cast_to<CollisionObject3D>(object)` to perform a safe cast and return null if the object is not of the expected type.
- This resolves issues where `RayCast3D.get_collider()` could return objects like `CSGShape3D`, leading to runtime errors and incorrect behavior.

Fixes: #12345
@Akshajk3 Akshajk3 requested review from a team as code owners December 14, 2024 06:31
@Sauermann
Copy link
Contributor

This is likely not the right way to fix the issue. The documentation should be updated.
Please be aware of the comment here: #100139 (comment)

@Akshajk3
Copy link
Author

Hi, sorry for the mistake. It is my first time contributing, and I was unsure of exactly what the tags meant. To clarify, does the "documentation" tag mean it is an issue with the docs that need to be updated, not the code?

@Sauermann
Copy link
Contributor

Thank you for your effort. No worries!
That is right: the code should not change, but rather the documentation needs to be updated to correctly describe the actual behavior.

@Akshajk3
Copy link
Author

Just a quick question, I was wondering if there was documentation for the source code itself, because I get a bit confused when looking through the codebase for the right files.

@Sauermann
Copy link
Contributor

You might find this a good place to start.

A raycast represents a ray from its origin to its [member target_position] that finds the closest [CollisionObject3D] along its path, if it intersects any.

@AThousandShips AThousandShips changed the title Fix: RayCast3D.get_collider does not return a CollisionShape3D (#100139) Fix: RayCast3D.get_collider does not return a CollisionShape3D Dec 14, 2024
@AThousandShips AThousandShips added this to the 4.x milestone Dec 14, 2024
@AThousandShips
Copy link
Member

Thank you for your contribution! Closing in favour of:

Which is the appropriate solution, thank you nonetheless!

@AThousandShips AThousandShips removed this from the 4.x milestone Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RayCast3D.get_collider does not return a CollisionShape3D
3 participants