0 votes

I want the Dead () method to start when the fireball hits the slime (enemy)
however the player and fireball code is written in gdscript although this is not such a big problem I think the slime code is written in gdnative.
the fireball (Area2D) uses the "body_entered" signal, but how to use the instance method through a parameter and how to do it through Cross-language scripting, for a better understanding here is an example of how I tried to do it:

var slime_node = slime_script.new ()
var slime_dead = slime_node.Dead ()
func _on_Magic_Blast_body_entered (body):
   if "Slime" in body.name:
     body.slime_dead
in Engine by (29 points)

1 Answer

+1 vote
Best answer

I can only share my experience from C#, but maybe it will help you. In C# you can call GDscript methods via the "Call"-function. You only need the name of the method for this.
If you want to call a GDnative function from GDscript, then this reddit post might help.

by (326 points)
selected by

I know how to call a method through the gdn code object, but I don’t know how to call it through the parameter in the body_entered (body) signal which is in the fireball code,
I need to call a method from the enemy, and I tried with call, but for some reason nothing happens but it does not crash as before

Have you tried the "register_method" that was suggested in the linked reddit post? If that doesn't work then maybe it's some kind of dependency weirdness.

I'm sorry, everything is already working, there just were no changes and I thought it was not working

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.