player not moving when tilting

Code seems fine however when i run the simulator in xcode or on my phone and tilt, the player doesnt move.

override func update(_ currentTime: TimeInterval) {     if let accelerometerData = motionManager?.accelerometerData {       physicsWorld.gravity = CGVector(dx: accelerometerData.acceleration.x * -50, dy: accelerometerData.acceleration.y * 50)     }

Do i need gamescene.sks because i deleted the grid and the file

Replies

Hello,

There isn't really enough code to go on here to provide a concrete suggestion. It looks like you are setting the physics world's gravity based on the current acceleration per frame, but there are a number of reasons that your "player" might not move, for one, it might not be a dynamic physics body (and therefore would not respond to changes in gravity), or it might not have a physics body at all.

You might find reviewing this article helpful: https://developer.apple.com/documentation/spritekit/getting_started_with_physics

i added plane.physicsBody?.isDynamic = true to my code but it still doesnt move. I dont think its my code. Do i need gamescene.sks?

You don't need to have a .sks file, assuming that you have set up your SKScene programatically. It may be best if you request technical support for this issue at https://developer.apple.com/support/technical/