如何在Godot代码中定义OcclusionrPolygon2D

发布于 2025-01-19 01:05:32 字数 237 浏览 1 评论 0原文

我使用的代码

    var shape: PoolVector2Array  = [Vector2(0,0), Vector2(0,70), Vector2(70,0), Vector2(70,70)]
set_occluder_polygon(shape)

由于类型不同而出现错误。我使用这个是因为 OcclusionrPolygon2D 有 PoolVector2Array Polygon

I am using this code

    var shape: PoolVector2Array  = [Vector2(0,0), Vector2(0,70), Vector2(70,0), Vector2(70,70)]
set_occluder_polygon(shape)

which gives error because of not having same type. I used this because OccluderPolygon2D has PoolVector2Array Polygon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜血缘 2025-01-26 01:05:32

我想您有一个lightoccluder2d,并且要设置其oxpluder(这是oxcluderPolygon2d)。如果已经有一个,则应该能够直接设置其点。类似的东西:

$LightOccluder2D.occluder.polygon = shape #PoolVector2Array

否则,您将必须创建oxCluderPolygon2d

var new_occluder := OccluderPolygon2D.new()
new_occluder.polygon = shape #PoolVector2Array
$LightOccluder2D.occluder = new_occluder

I presume you have a LightOccluder2D and you want to set its occluder (which is a OccluderPolygon2D). If it already has one, you should be able to set its points directly. Something like this:

$LightOccluder2D.occluder.polygon = shape #PoolVector2Array

Otherwise, you would have to create a OccluderPolygon2D:

var new_occluder := OccluderPolygon2D.new()
new_occluder.polygon = shape #PoolVector2Array
$LightOccluder2D.occluder = new_occluder
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文