Can't use tween.Finished in C#

Godot Version



I am following a tutorial on how to make lasers in godot and the tutorial is in GDScript. But I am trying to convert the code to C#.

public async void Activate(float time)
tween = GetTree().CreateTween();
Visible = true;
beamParticles.Emitting = true;
endParticles.Emitting = true;
tween.TweenProperty(mesh, “TopRadius”, beamRadius, time);
tween.TweenProperty(mesh, “BottomRadius”, beamRadius, time);
tween.TweenProperty(beamProcessMaterial, “ScaleMin”, 1, time);
tween.TweenProperty(endBeamProcessMaterial, “ScaleMin”, 1, time);
await tween.Finished;

With this piece of code I get an error called this:
The event ‘Tween.Finished’ can only appear on the left hand side of += or -= CS0079

I have made research on how to solve this and I looked at the godot and C# documentation for help but it was all in vain. Any help is appreciated. Thank you in advance.

See the documentation

Thank you for your reply. I did not know I had to look at await. I get no errors in the code but now when I run the game I get an error called “started with no tweeners” in the engine. Would you know anything about that?

where is this example you are looking at?

What do you mean by example?

you said you are following a tutorial. where do i find this tutorial

Apologies for not understanding what you mean. Here it is:

in the documentation examples, there is often a c# tab you can click. the documentation says to do something like this. i’ve never messed with tweens so i got no idea if it will work.

public async void Activate(float time) {
	var tween = GetTree().CreateTween();
	await ToSignal(tween, Tween.SignalName.Finished);

I had already done what you said with the help of the documentation that athousandships gave me. I was getting an error in the code editor before doing that. Now I get an error in the game engine called : started with no tweeners. I learned that someone solved this by creating the tween where it is used but I already do that so I got no idea how to solve this one.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.