Im making my first game, a flappy bird type game, using godot in C# and I made a script that clones pipes and makes them move left but I’m having trouble calling the process at all, this process would affect the clone
using Godot;
using System;
using System.Collections;
public partial class Pipe1 : Sprite2D
{
private Node2D cloned;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
private void _on_timer_timeout()
{
SceneTree sceneTree = GetTree();
PackedScene origScene =
GD.Load<PackedScene(“res://flappyWappy.tscn”);
cloned = (Node2D)this.Duplicate();
sceneTree.Root.AddChild(cloned);
cloned.Connect(_OnPipeProcess);
}
private void _OnPipeProcess(float delta)
{
cloned.Position += new Vector2(-1 * delta * 25, 0);
}
// Called every frame. ‘delta’ is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}
Firstly: What error does cloned.Connect(_OnPipeProcess); return?
Seconldy: are you sure you are calling _OnPipeProcess(float delta) at some point? Most of the time something doesn’t work on my game, I forgot to call a method.
CS7036: There is no argument given that corresponds to the required parameter ‘callable’ of ‘GodotObject.Connect(StringName, Callable, uint)’ E:\GodotProjects\Pipe1.cs(24,10)
I think I can help you now.
You are using the method wrong. If you read the docs, you will see, that you need to provide the signal name, as well as a method, wich will be called.
Ok, I need to clarify a few concepts first. The pipeline is rendered within the screen, so you can first instantiate a certain number of pipelines, such as 16? Then when the bird moves, you only need to change the position of each pipeline.
Yeah thats possible. It seems like you already instantiate your nodes. The movement of the pipes shouldn’t be too hard. You could just offset the position of the pipe each frame _OnProcess.