How to make SKSpriteNode follow another SKSpriteNode that has a physical body

Using swift, I try to make SKSpriteNode(which does not have a physical body) follow another SKSpriteNode that has a physical body. I want this to be done when there is contact between the sprite with the physical body and another physical body. I read about tuning SKContsraints, but they have a range and often drop out or change. I want the sprite to be respected exactly. How can I do that?

+4
source share
1 answer

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

nodeWithoutPhysicsbody.position = nodeWithPhysicsbody.position

, node node , .

0

Source: https://habr.com/ru/post/1607875/


All Articles