Attention | Topic was automatically imported from the old Question2Answer platform. | |
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
if(Input.IsActionJustPressed("test"))
{
var projectile = (PackedScene)ResourceLoader.Load("res://Projectile.tscn");
var instance = projectile.Instance();
GetParent().AddChild(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