gpt4 book ai didi

swift - SceneKit 粒子系统未出现

转载 作者:行者123 更新时间:2023-11-30 10:49:02 24 4
gpt4 key购买 nike

我正在尝试使用 Scenekit 中的粒子系统向火箭添加火焰。粒子文件看起来很好,我没有收到任何错误,但当我运行应用程序时,粒子没有出现。reactor.scnp 和spark.png 都位于art.scnassets 文件夹以及主应用程序文件夹中。

  @objc func sceneTapped(recognizer: UITapGestureRecognizer) {
let location = recognizer.location(in: sceneView)

let hitResults = sceneView.hitTest(location, options: nil)
if hitResults.count > 0 {
let result = hitResults[0] as! SCNHitTestResult
let node = result.node

let physicsBody = SCNPhysicsBody(type: .dynamic, shape: nil)
rocket.physicsBody = physicsBody
let direction = SCNVector3(0, 3, 0)


let rocketshipNode = rocket

let reactorParticleSystem = SCNParticleSystem(named: "reactor.scnp", inDirectory: nil) //SCNParticleSystem(coder: "art.scnassets/reactor")
print(reactorParticleSystem)
let engineNode = rocket.childNode(withName: "node2", recursively: false)
print(engineNode)

// 3
physicsBody.isAffectedByGravity = false
physicsBody.damping = 0

// 4
let collider = [floor]
reactorParticleSystem?.colliderNodes = collider as? [SCNNode]
// 5
engineNode?.addParticleSystem(reactorParticleSystem!)

// 6
let action = SCNAction.moveBy(x: 0, y: 0.3, z: 0, duration: 3)
action.timingMode = .easeInEaseOut
rocketshipNode!.runAction(action)



}
}

最佳答案

不确定问题是什么,但我重新创建了粒子系统文件,它似乎工作正常。

关于swift - SceneKit 粒子系统未出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55064553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com