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

Issue with connecting signal BodyEntered (area) #103

Closed
DarthvaderBn opened this issue May 29, 2021 · 1 comment
Closed

Issue with connecting signal BodyEntered (area) #103

DarthvaderBn opened this issue May 29, 2021 · 1 comment

Comments

@DarthvaderBn
Copy link

DarthvaderBn commented May 29, 2021

Code:

gdobj Onion of Spatial:

    var swampObject: Swamp
    var area_touch: Area

    method ready*() =
        self.area_touch = self.getNode("Area") as Area
        discard self.area_touch.connect("body_entered", self , "on_area_touch_body_entered")
    
    proc onAreaTouchBodyEntered*(body: Node) {.gdExport.} =
        self.swampObject.takedOnion()
        self.queueFree
        print("Less goo")

I'm getting error
Could not access value because it is nil. (body: Node)

Changing proc to method

    method onAreaTouchBodyEntered*(body: Node) {.gdExport.} =
        ...

Warning:
use {.base.} for base methods; baseless methods are deprecated [UseBase]

Error:
e m i t _ s i g n a l : E r r o r c a l l i n g m e t h o d f r o m s i g n a l ' b o d y _ e n t e r e d ' : ' S p a t i a l ( o n i o n . g d n s ) : : o n _ a r e a _ t o u c h _ b o d y _ e n t e r e d ' : M e t h o d n o t f o u n d . .

@DarthvaderBn
Copy link
Author

DarthvaderBn commented Jun 12, 2021

I found out the problem
i need to change Node to other type

Example:
I need to check if player is entered
So, i need to change type to KinematicBody

proc onAreaTouchBodyEntered*(body: KinematicBody) {.gdExport.} =
        self.swampObject.takedOnion()
        self.queueFree
        print("Less goo")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant