Better way to send information between scripts

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

Hello y’all,

I am currently working on a little test project to learn Godot.
Today I was playing with signals but I ran into a situation witch made signals feel kinda bad to use.
In my project im trying to create a projectile from the player and to have it move in a direction for a certain distance for a certain amount of time. Ive got this working without a issue but to send the direction, distance, and time I have to create a singal than emitit and then disconnect the signal so im not sending signals to other projectiles.
This feels like a really clunky way to send information between the two scripts especial because this information is only needed on creation of the projectile.

Here is my code

        var projectile = (PackedScene)ResourceLoader.Load("res://Projectile.tscn");
        var instance = projectile.Instance();
        Connect(nameof(Shoot), instance, "Shoot");
        EmitSignal(nameof(Shoot), new object[] {movementVector.Normalized(), 15, 0.35});
        Disconnect(nameof(Shoot), instance, "Shoot");

TL;DL: Is there a better way to send information on creation of a script other than signals

:bust_in_silhouette: Reply From: wombatstampede

I’m not using c# but GDScript but probably this is similar.

You could just directly call a method of that new instance. And if that doesn’t work then you could use call_deferred (This is a method of “Object”) probably CallDeferred() for c#?