In SceneKit, I had a problem on collision of two dynamic spheres, when the one strikes to another with fast speed, it was passing through inside of it. After i have reduced physicsWorld.timeStep value from 1/60 to 1/300, collision of Spheres becomes perfect. However in this moment, if sphere strikes to static wall, it started to slide along the wall (like sticky) instead of being reflected from wall. Ball started to lose so much energy after colliding to wall.

When timeStep was 1/60, ball was bouncing on the wall even in so low speeds, instead sticking to wall. What kind of parameters are affected in physicsBody of the wall or ball by the timeStep?

Wall Parameters;

let ballMass: CGFloat = 0.08
physicsWorld.timeStep = 1/300

let wallGeometry = SCNPlane(width: (maxX - minX), height: wallHeight)
wallGeometry.firstMaterial?.diffuse.contents = UIColor.red
wallGeometry.firstMaterial?.isDoubleSided = true
let shapeWallGeometry = SCNPhysicsShape(geometry: wallGeometry, options: nil) //su an lik bir ise yaramiyor

let wallNode = SCNNode(geometry: wallGeometry)

wallNode.position = SCNVector3( x: Float(xCenter), y: Float(minY-cushionHeight/2), z: Float(cushionHeight)/2 )

wallNode.physicsBody = SCNPhysicsBody(type: .static, shape: shapeWallGeometry)
wallNode.physicsBody?.restitution = 0.82
wallNode.physicsBody?.friction = 0.91

wallNode.physicsBody?.categoryBitMask = PhysicsCategory.WallType.rawValue | PhysicsCategory.GravityType.rawValue
wallNode.physicsBody?.collisionBitMask = PhysicsCategory.BallOneType.rawValue | PhysicsCategory.BallTwoType.rawValue | PhysicsCategory.BallThreeType.rawValue | PhysicsCategory.GravityType.rawValue
wallNode.physicsBody?.contactTestBitMask = PhysicsCategory.BallOneType.rawValue | PhysicsCategory.BallTwoType.rawValue | PhysicsCategory.BallThreeType.rawValue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.