Godot Version
4.4
Question
I am trying to use the physics server to create monitorable areas (as bullets for a bullet hell), but cannot seem to detect them with my normal character. An area 2d node in the scene with the same details gets picked up just fine, but the physics server version seems invisible. Any help would be appreciated!
public partial class ProjectileSpawnerTest : Node2D
{
[Export] private Texture2D texture;
private Rid ci_rid;
private Rid tex_rid;
private Rid world;
private Rid area;
private Rid shape;
public override void _Ready()
{
// Setup
world = GetWorld2D().Space;
// Canvas item
ci_rid = RenderingServer.CanvasItemCreate();
tex_rid = texture.GetRid();
RenderingServer.CanvasItemSetParent(ci_rid, GetCanvasItem());
RenderingServer.CanvasItemAddTextureRect(ci_rid, new Rect2(-texture.GetSize() / 2, texture.GetSize()), tex_rid);
// Area 2D
area = PhysicsServer2D.AreaCreate();
shape = PhysicsServer2D.CircleShapeCreate();
PhysicsServer2D.ShapeSetData(shape, 20f);
PhysicsServer2D.AreaAddShape(area, shape);
PhysicsServer2D.AreaSetSpace(area, world);
PhysicsServer2D.AreaSetCollisionLayer(area, 32);
PhysicsServer2D.AreaSetMonitorable(area, true);
PhysicsServer2D.AreaSetShapeDisabled(area, 0 , false);
// Transform
Transform2D transform_canvas = new Transform2D(0, new Vector2(0.32f, 0.32f), 0, Vector2.Zero);
Transform2D transform_projectile = Transform2D.Identity;
PhysicsServer2D.AreaSetTransform(area, transform_projectile);
RenderingServer.CanvasItemSetTransform(ci_rid, transform_canvas);
}
}