I tried to get Apple’s SCNPhysicsVehicle class working nicely, from scratch (no template project), and learnt a whole lot of stuff about how to do that successfully. I may add to this page over time, to collect further wisdom.

It really did drive me crazy for a number of days, as I really wanted to make it work by creating the most basic car in the scene editor: a rectangular block for the chassis, and four cylinders for the wheels. The only reason I added the pyramid to the top of the chassis is to make it more obvious which way the ‘car’ is facing!

I got some properly wacky and confusing results, until I figured all of this out.

  • Make sure no nodes have any scaling on them.
    • If creating from primitives, use the width/height/length attributes to get the right dimensions, instead of scaling.
    • If you use scaling instead – e.g. to make a cylinder flatter to look more like a wheel, or to lengthen a box to make it look like a car body (use your imagination) – then weird things happen.
  • Make sure no nodes have any Euler rotation on them.
    • If your wheels have any rotation on them in the scene, that is then undone when your wheels are displayed . If you’re using primitive cylinders as wheels, this is a problem, since they need rotating to not stand on end. The solution is to use imported models instead of a primitive or add a child node that then contains your rotated wheel. Either that your child node or model have the correct origin for wheel attachment point, and no rotation.
  • SCNPhysicsVehicle seems to make some built-in assumptions that your vehicle and its wheels will be aligned in the scene file such that it drives backwards and forwards along the z-axis.
    • If you build the scene so that it is along the x-axis (so at 90 degrees to z-axis) then the wheels get oddly rotated 90 degrees and roll end over end instead of how they should.
  • Steering wouldn’t work when I set steering angle as part of car setup code, but did work when setting in delegate callback each frame. Perhaps it’s too early during setup.
  • Only the main chassis geometry seems to count for collisions – the wheels will go beneath the floor if you roll onto the side, and a pyramid on top will also if rolled onto its roof. Only the main box physics seems to be effective. Perhaps I haven’t set things up quite right.
  • For applyEngineForce() and applyBrakingForce() it seems the docs lie and you do need to reset to zero if you want to remove the effect. My first attempt ended up with brakes and throttle both stuck on and strange behaviour as a result.