1
votes

I wanted to do a simple asteroids games where the asteroids go from far to bypass you (z>0) in SceneKit.

let moveAction = SCNAction.move(to: SCNVector3(0, -10, 10), duration: 2)
rockNode.runAction(moveAction)

Says I have a spaceship in Z axis 0, even though I can visually see the asteroids pass through the spaceship, the collision detection does not occurred. The collision only happened if the end point of the moveAction ends in Z axis 0 and in the same location as the spaceship.

Does detection only occurred after the moveAction ended (thus will not detect collision)? If yes, what solution do I have in detecting the collision during the asteroids movement?

2

2 Answers

0
votes

did you set the isDynamic to true on both of your objects? and they both need to have different categoryBitmasks otherwise SceneKit will treat them as the same objects (can't comment don't have 50 rep yet) if not then do so collision should happen even when moving an object programmatically

0
votes

Make the physics body as: kinematic. So it can detect collision even during SCNAction.

eg:

rockNode?.type = .kinematic

Or you can set it from Physics Inspector

Keep coding....... :)