【问题标题】:GameplayKit GKMeshGraph obstacles bug?GameplayKit GKMeshGraph 障碍错误?
【发布时间】:2016-10-10 16:18:32
【问题描述】:

我觉得这可能是一个错误,任何人都可以重现或看到我做事的一些错误。

我正在尝试将 GKPolygonObstacle 添加到适用于 iOS 或 macOS 的 Playground 中的 GKMeshGraph。

import Cocoa
import SceneKit
import GameplayKit

let points = [float2(1,1), float2(2,1), float2(2,2), float2(1, 2)]

let obstacle = GKPolygonObstacle(points: points)

let graph = GKMeshGraph<GKGraphNode2D>(
    bufferRadius: 0,
    minCoordinate: float2(0,0),
    maxCoordinate: float2(3,3))

graph.addObstacles([obstacle])
graph.obstacles // empty, should have 1 obstacle in it!
graph.triangulate()
graph.obstacles // still empty

这确实会在图表中添加节点,但无论我做什么,我都无法填充障碍。

Apple API 看起来很简单。我错过了什么吗?

谢谢

Xcode:版本 8.0 (8A218a)

Swift:Apple Swift 3.0 版 (swiftlang-800.0.46.2 clang-800.0.38)

【问题讨论】:

  • 我还使用 SKNode.obstacles(fromNodeBounds) 从节点创建了障碍,结果相同
  • 是的,看起来像一个错误。我建议filing it with Apple。
  • 这个错误有什么更新吗?我刚刚遇到了同样的问题。

标签: ios swift macos sprite-kit gameplay-kit


【解决方案1】:

你必须在添加障碍之前设置 triangulationMode graph.triangulationMode = [.vertices,.centers]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-04
    • 1970-01-01
    • 2018-10-17
    • 2019-07-05
    • 1970-01-01
    • 2021-07-15
    • 2017-10-01
    • 2015-07-28
    相关资源
    最近更新 更多