我正在尝试在 C# 中对 Area3D 使用 BodyShapeEntered 信号。我不知道这次活动的代表应该是什么样子。我收到以下编译错误:“‘OnCollision’没有重载与委托‘Area3D.BodyShapeEnteredEventHandler’匹配”不幸的是,我找不到任何有关我应该为此处理程序使用哪些参数的信息(如果不是)。我的代码与https://docs.godotengine.org/en/4.2/classes/class_area3d.html#signals中的描述匹配
我使用的是4.2版本。这是我的代码:
using Godot;
using System;
public partial class LocationExit : Area3D
{
public static readonly PackedScene DefaultExitScene = ResourceLoader.Load<PackedScene>("res://Overworld/Overworld.tscn");
public PackedScene ExitScene;//alternate scene to exit to
string StoryVariableOnExit;//increments this variable in the story on collision
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
this.BodyShapeEntered += OnCollision;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
private void OnCollision(Rid body_rid, Node3D body, int body_shape_index, int local_shape_index)
{
//cannot use, this will not compile
}
}
我相信你需要使用
long
而不是int
: