我根据纹理为玩家(兽人)创建了一个物理物体。
player.physicsBody = SKPhysicsBody(texture: player.texture!, size: player.texture!.size())
player.physicsBody?.isDynamic = true
player.physicsBody?.usesPreciseCollisionDetection = true
player.physicsBody?.categoryBitMask = CollisionCategoryBitmask.Player
player.physicsBody?.collisionBitMask = 1
player.physicsBody?.restitution = 0
player.physicsBody?.friction = 1
ground?.physicsBody?.restitution = 0
并且通过施加冲动来创建跳跃动作
func jumpPlayer(){
player.physicsBody?.applyImpulse(CGVector(dx: 0, dy: 60))
}
跳跃后,一旦降落,玩家节点似乎失去平衡并掉落。
如何避免这种情况?
答案 0 :(得分:0)
可以通过将allowRotation设置为false来解决此问题
player.physicsBody?.allowsRotation = false