how to call enemy instance function via Cross-language scripting but enemy code in gdnative

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By F0remNKB

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
:bust_in_silhouette: Reply From: MagnusS

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.

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

F0remNKB | 2021-09-17 09:23

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.

MagnusS | 2021-09-18 10:17

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

F0remNKB | 2021-09-18 13:48