我正在尝试加入一个带炮塔的坦克,但由于这个联合,整个模型都在晃动,你知道导致这种行为的原因吗?
项目链接:Project
这就是我的做法:
SCNNode *tankNode = [extraScene.rootNode childNodeWithName"Main_Body" recursively:YES];
[tankNode setScale:SCNVector3Make(0.003, 0.003, 0.003)];
[tankNode setPosition:SCNVector3Make(0, 1, 0)];
[tankNode setPhysicsBody:[SCNPhysicsBody dynamicBody]];
[tankNode setRotation:SCNVector4Make(0, 1, 0, -M_PI_2)];
[scene.rootNode addChildNode:tankNode];
SCNNode *turretNode = [tankNode childNodeWithName"Turret" recursively:YES];
turretNode.physicsBody = [SCNPhysicsBody staticBody];
SCNNode *gunNode = [turretNode childNodeWithName"gun" recursively:YES];
gunNode.physicsBody = [SCNPhysicsBody staticBody];
SCNPhysicsHingeJoint *gunJoint = [SCNPhysicsHingeJoint jointWithBodyA:turretNode.physicsBody axisA:SCNVector3Make(0,0,1) anchorA:SCNVector3Make(0.1,0.1,0.1) bodyB:gunNode.physicsBody axisB:SCNVector3Make(0,0,1) anchorB:SCNVector3Make(0.1,0.1,0.1)];
[scene.physicsWorld addBehavior:gunJoint];
SCNPhysicsHingeJoint *turretJoint = [SCNPhysicsHingeJoint jointWithBodyA:turretNode.physicsBody axisA:SCNVector3Make(0,1,0) anchorA:SCNVector3Make(0.1,0.1,0.1) bodyB:tankNode.physicsBody axisB:SCNVector3Make(0,1,0) anchorB:SCNVector3Make(0.5,0.5,-0.1)];
[scene.physicsWorld addBehavior:turretJoint];
我认为有两个问题:
关于ios - 场景套件中的铰链接头发生奇怪的晃动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24718770/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |