For those writing in C#, make sure you use GodotObject as the interactCastResult variables type in order to access the HasUserSignal method. For another helpful tip, my ConnectParent() method looks like this: public void ConnectParent() { parent.AddUserSignal("focused"); parent.AddUserSignal("unfocused"); parent.AddUserSignal("interacted"); parent.Connect("focused", Callable.From(InRange)); parent.Connect("unfocused", Callable.From(Unfocused)); parent.Connect("interacted", Callable.From(OnInteracted)); }
I have a problem with objects that gets destroyed after interaction. If i use queue_free, object is still cashed, context ui is still on screen and if i press interact again, game is crashed. Tried to clear cashed manually but i can't figure out how. Does anyone know how to do that?
Just making sure I understand correctly, you could have made the focus/unfocus prints happen in the component and just emitted the signal in the player controller right? The next episode will do the highlighting logic over there I'd assume? Otherwise what was the point of setting up those signals?
@@stayathomedev I would imagine passing `parent.connect("focused", in_range)` would be preferred over the "callable with string", guessing that it'd give the compiler more info as a function than a dynamic string. I'm not sure why but passing functions as strings feels wrong - any more info on this & where it says the preference in docs?
@@stayathomedevIt's more explicit but it can't be picked up by the interpreter. Callable casting with (object, string) is useful for trying to refer to a method that may not exist. In this case, you can call in_range (as a literal without quotes) to access the method as a callable directly. The engine can resolve the reference to the method in the text editor since its available in the same script, unlike casting which only shows an error at runtime if the method doesn't exist.