#Troubleshooting - Checking for Interactable Items in Area3D

1 messages · Page 1 of 1 (latest)

fallen island
#

Hi everyone, I've started putting together the base mechanics for a project in Godot 4.2. I'm intending to have a system where players can interact with items that enter an Area3D in front of them, as long as they're of my custom Interactable type. So far, it hasn't been working as intended. My Area3D (with a CollisionShape3D parented to it) doesn't seem to detect my Interactables at all (which have a MeshShape3D and a CollisionShape3D parented to them). I can confirm that I set up my Input Map properly, so it doesn't just come down to having no binding for "Action".

Attached I'll have screenshots of my Player's node hierarchy, the code in the Player script that handles interaction, and the setup of my Interactable script and node hierarchy. Can anybody help me understand if I've missed something? Thank you

brazen dock
#

I'd start by printing inside "if body is Interactable"; if it prints then the transform code might be confused, possibly with the notion of an infinite-length float instead of checking for a null value. otherwise, it might be where you're calling check_for_interaction?

fallen island
#

Yeah, looks like the "if body is Interactable" doesn't return anything. When I add a print to the "for body in bodies", it looks like it prints for the floor, too. So I just readjusted the bounds of my CollisionShape to see if that changes anything

#

Okay, so I got the "for body in bodies part figured out. Adding a StaticBody3D at least allows the objects to be detected by the Area3D, which I guess makes sense since it's looking for bodies and not just a CollisionShape. But it won't detect that the body has in Interactable script attached to it

fallen island
#

I had to change a number of things around, but I've figured something out that accomplishes what I was intending. Using a bunch of prints and switching what I was checking for the script on from bodies to areas, I was able to figure out where things were breaking down

brazen dock
#

it might be important where the Interactable script is too? it might expect the script to be on the PhysicsBody2D inheritor or the root node for an Interactable.tscn or something...