I’ve written up a class that is used for managing player interaction. I was only getting interaction responses out of some instances and while debugging I eventually resorted to having the class print information about the instance on any input from the player. After doing so I can see that the instances that aren’t functioning properly wont respond to any input (let alone all the other logic that governs interactions). Instances that are functioning normally in interactions also properly respond to any input from the player. Approximation of the debug code is included below.
Is there anything that governs whether one instance of a class does/does not see inputs? To be clear, I didn’t write anything into the class that turns listening to inputs on or off and I can see that the instances that should be in the game are there - test of their existence show they exist.
func _input(event):
if event.is_action_pressed("ui_accept"):
print(self.name)
I have a class called InteractivityTarget, it’s function is to watch for player inputs and, under the right circumstances, tell one instance of another class called InteractivityLogic to ‘do your thing’ - this could be launching dialog, loading a level, etc.
I have a test level with one NPC who has an instance of InteractivityTarget that watches for conditions to launch the NPC’s InteractivityLogic that does an NPC shout. I also have a door that has an InteractivityTarget instance that launches the door’s InteractivityLogic that loads a level.
The NPC’s shout interactivity works fine, but the doors interactivity doesn’t work. While trying to debug what’s going on, I altered the InteractivityTarget class so that on any ui_accept input, the instance prints its name and whether or not interactivity is armed (this interactivity armed thing isn’t super important at this point).
After making this change to the InteractivityTarget class, the NPC’s InteractivityTarget instance will print it’s name and whether it’s armed any time I press the space bar, but the door’s InteractivityTarget instance doesn’t print anything.
I’m at a loss as to why the door wouldn’t be responding to the input. When the player collides with the collision shape for these interactables it prints the interactable name and I can see the name of the door coming up, so it definitely looks like it exists (I have no idea why it wouldn’t).
The simplified node graphs looks something like this:
The npc is spawned by the Level node, so I’m not exactly sure where it shows up in the Level’s node tree while the game is actually running, I guess it’d be a child node of Level. I can run the game and print out the node tree while running if that’d be useful.