-
Notifications
You must be signed in to change notification settings - Fork 117
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
Interaction Ray + Shapecasting for easier object interaction #281
Interaction Ray + Shapecasting for easier object interaction #281
Conversation
OvercastInteractive
commented
Sep 20, 2024
- Uses the existing raycasting behavior for when aiming directly at the target interactable
- If not aiming directly at the target interactable, a shapecast is used to detect any nearby interactables
- If raycasting a body that is not interactable, such as a tabletop, moves a 'hotspot' node to the raycasted point
- The hotspot point is used as a reference for any shapecast hit colliders to compare distances with all other hits
- The closest interactable collider to the hotspot is selected as the target interactable
…hters to debug its behavior This commit modifies the existing InteractionRaycast.gd and to a lesser extent the PlayerInteractionComponent.gd. InteractionRaycast now uses a shapecast when the raycast doesn't hit a valid collider. If the shapecast hits multiple valid colliders it will use a 'hotspot' and judge distances between it and valid colliders to determine which object the player is more likely intending to pick up. There is a known issue regarding the ShapeCast3D node reference being lost on scene change.
Hey,thanks so much for this, this is quite simple but yields amazing results! I get a weird issue though: This happens whether I start directly in the Laboratory scene or transition to it from the Lobby scene. |
I expected the highlighters to be removed after a little more testing (as I found looking into cabinets and drawers toward multiple carryables produced unexpected/undesired detection results) and the hotspot can be converted into a |
In order to get the Laboratory scene to work I had to add null checks and assignments for every null reference at the top of if hotspot == null: if hotspot != null: It's like their references are lost or cleared before every call. 🤨 |
The issues are due to the Enemy. I didn't realize they were using the same code, sorry about that! Here's the error code: |
- Turned the Interaction Raycast into a packed scene, to keep child node structure consistent. This should fix reference issues with the Enemy using an interaction raycast. - Updated the player and enemy packed scene to use said interaction raycast packed scene. - Added the option to turn debug shapes on/off.
Aaah, the enemy is pretty new so I totally forgot about this! Take it for a spin, but I'd wager this is now ready to merge. |
- Turn debug shapes off on ready if they're disabled and ensure they don't turn on any point while playing - Removed a null ref check having to do with the ShapeCast3D not found for enemy interaction raycast on scene change
I made a couple of minor changes, but yeah, everything now seems to work well! |
Awesome! Again, thanks so much for your work on this. You implemented this way better than I could have. |