Chapter 20: Advanced Game Physics
前言
大綱
Creating an infinite ground plane
var groundNode: SCNNode!
/////////////////////////////
func createFloorNode() -> SCNNode {
// 利用SCNFloor
let floorGeometry = SCNFloor()
floorGeometry.reflectivity = 0.0
let floorMaterial = SCNMaterial()
floorMaterial.diffuse.contents = UIColor.white
// This is a clever hack that hides the floor but keeps things like reflections and shadows visible.
floorMaterial.blendMode = .multiply
floorGeometry.materials = [floorMaterial]
let floorNode = SCNNode(geometry: floorGeometry)
floorNode.position = SCNVector3Zero
floorNode.physicsBody = SCNPhysicsBody(type: .static, shape: nil)
floorNode.physicsBody?.restitution = 0.5
floorNode.physicsBody?.friction = 4.0
floorNode.physicsBody?.rollingFriction = 0.0
return floorNode
}Adding engine force
Adding steering
Limiting the speed
Last updated