Search code examples
swiftsprite-kitskphysicsbody

Changing the speed at which an object drops when affected by gravity.(SpriteKit)


I have an object that needs to fall down the scene when the game starts. When the player taps the screen the object moves back to the top of the scene. In order to make the object fall I set it to be affected by gravity. This works fine but the problem is the object falls down the screen to fast. Can I set the speed at which the object falls do to gravity to a different speed. If so how do I do this.


Solution

  • You can reduce the gravity of the physicsWorld. Another option is to apply a force in the opposite direction to each object. If the gravity is -9.8 in the y axis, you could apply a force from +0-9.8 in the y axis to slow the object down.

    EDIT: Changing the mass does not affect the speed.