4

I'm moving the camera node of my SCNScene scene along the z-axis using the following code:

let moveTo = SCNAction.moveTo(SCNVector3(x:0,y:0,z:-40), duration: 40); 
cameraNode.runAction(moveTo)

I would like given an event (like GameOver event fired by my game) to smoothly decelerate the camera until stop it.

How can smoothly stop moving the camera?

chiarotto.alessandro
  • 1,491
  • 1
  • 13
  • 31
  • This is a very old post, but this comment may help someone. I'm not sure if it would work in this case, but you can do: `gameView.defaultCameraController.inertiaFriction = 0.01` – George Oct 10 '18 at 17:12

2 Answers2

1

SCNAction has a "timingMode" property you can set to "EaseOut"

Toyos
  • 4,024
  • 15
  • 16
  • The problem is that camerNode has associated a running action with duration 40 sec. Now I would like to stop moving the cameraNode. I can remove all action associated with the camera node but in this way cameraNode will not smoothly decelerate... – chiarotto.alessandro Aug 06 '15 at 20:59
0

Messy, but you could use Physics:

At the moment the GameOver event is fired, add a dynamic physics body to the node of the camera, give it the current velocity of the camera, and apply damping to make it slow down. This will give a vast amount of control of the slowdown, too. Just be sure the node is not subject to gravity, as that will see it fall without grace.

Confused
  • 6,048
  • 6
  • 34
  • 75