Hi again! I am currently working on a game with a team and we want to recreate a Peggle mini-game. I've made some significant progress thanks to some YouTube videos but they seem to be done in Godot 3 and I'm working in Godot 4. I'm still relatively new to working on game dev and Godot and would like some help pls!! I've been stuck on this for a couple of weeks and can't seem to figure out whats wrong.
Im running into this problem with the pegs in the game that won't change color and disappear... i keep getting errors when I make changes in the code
using Godot;
using System;
public partial class pegDestroy : Node
{
[Export]
public double timeDestroy = 3.0f;
double timeCount = 0f;
bool isOn = false;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
// var area = this.GetParent().GetChild<Area2D>(3);
// area.Connect("body_entered", _on_body_entered);
GetNode<Area2D>("../../Area2DNodeName").Connect("body_entered", this, "_body_entered");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
if(isOn){
timeCount += delta;
if(timeCount > timeDestroy){
Node body = this.GetParent();
body.GetParent().RemoveChild(body);
body.Dispose();
}
}
}
public void _body_entered(Node body){
GD.Print("detect" + this.GetParent().Name);
if(body.IsClass("RigidBody2D")&& body != GetParent()){
isOn = true;
var sprite = GetParent().GetNode<Sprite>("Sprite");
if(sprite != null){
sprite.Modulate = new Color(0.5f,0.5f,0.5f);
}
}
}
}