4

Using swift, I am trying to make a SKSpriteNode (that doesn't have a physics body) follow another SKSpriteNode that has a physics body. I want this to be done when there is contact between the sprite with a physics body and another physics body. I read about setting SKContsraints but these have a range and often fall out or vary. I want the sprite to be followed precisely. How can this be done?

chronos
  • 517
  • 1
  • 5
  • 14
  • What kind of effect do you want? Do you want it to be like a stick is connecting them or do you want one of them to follow closely behind,ecentually hitting the sprite if it stays still? – J.Doe Sep 17 '15 at 21:48

1 Answers1

0

Make sure your scene is a SKPhysicsContactDelegate. Then put this in your didBeginContact() method.

nodeWithoutPhysicsbody.position = nodeWithPhysicsbody.position

If you want the node without the physics body to always follow the node with the physics body, then put that line of code in the update method.

Moody3939
  • 3
  • 4