Max Hudson
Max Hudson

Reputation: 10206

Setting Spritekit gravity source

Is there any way to set an x,y coordinate that gravity pulls towards?

We want to suck a number of objects with physicsbodies towards a point as if it was a black hole.

Upvotes: 3

Views: 246

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

Not for the regular world gravity.

To achieve this effect, you have to apply to each body an impulse every frame. The strength and direction of the impulse depends on the distance of the body (node) to the gravity source's position.

Upvotes: 1

Related Questions