简体   繁体   English

从SCNPhysicsBallSocketJoint中删除弹性

[英]Remove Springiness From SCNPhysicsBallSocketJoint

I'm building my first app in Swift and it's based on the bimini ring toss game you see in bars with a ring attached to a string from the ceiling. 我正在Swift中构建我的第一个应用程序,它基于Bimini环抛游戏,您在酒吧看到的环上有一个环,环从天花板串在绳子上。 I'm using a SCNPhysicsBallSocketJoint to connect a bunch of small spheres to act like a string/rope. 我正在使用SCNPhysicsBallSocketJoint连接一堆小球,以使其像弦/绳子。 I've got some early results that are good but the spheres are way too springy in their connection. 我得到了一些不错的早期结果,但这些领域之间的联系过于弹性。 The repo is here if you want to run it yourself but here's the code for connecting the spheres. 如果您想自己运行该仓库,则在这里 ,但是这里是连接球体的代码。

/** Generate our rope links **/
    var cnt:Float = 0.0
    var previousLink: SCNNode = ropeObject.getRope()
    var links :[SCNNode] = [SCNNode]()
    while cnt < 4.0 {
        let link = ropeObject.getLink( y: Float(cnt) )
        links.append(link)

        let joint = SCNPhysicsBallSocketJoint(
            bodyA: link.physicsBody!,
            anchorA: SCNVector3(x: -0.05, y: -0.05, z: -0.05),
            bodyB: previousLink.physicsBody!,
            anchorB: SCNVector3(x: 0.05, y: 0.05, z: 0.05)
        )
        scnScene.physicsWorld.addBehavior(joint)

        previousLink = link
        cnt += 0.1
    }

Try to significantly increase mass property of your spheres, it will result less springiness. 尝试显着增加球体的mass特性,这将减少弹性。

Also, Chris, thank you so much for posting this project in your blog, it helped me a lot with my rope-like object. 另外,克里斯,非常感谢您将此项目发布到您的博客中,这对我的绳索状对象很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM