0
votes

Hi guys i want to apply slow motion in upward direction,

what i am confused, when i applyimpulse

[self.physicsBody applyImpulse:CGVectorMake(0, 60)];

it does applyimpulse with required speed as it measure from its velocity mass and other physics things

what i need to applyImpulse but with controlling speed of impluse that is applied on object on which impulse is being applied.

i tried to set even self.speed but got no success,
how one can achieve desired impluse or Force on an sprite with controlling over speed.

are there some properties that should i set for the SKSpriteNode before applying Impulse,

or some thing else? Any suggestion or thoughts will be appreciated

Thanks

2

2 Answers

1
votes

All forces are applied as actual physics forces on physics bodies.

The resulting movement of the body that had the force applied to it depends on not just the magnitude and direction of the force but also the size and density (i.e. mass) of the body the force is being applied to and where on the body the force is applied.

I'm not entirely sure what you mean when you say you need "controlling speed of impulse" though.

Maybe what you need is not to use forces at all but to move the node manually.

You could use an action [SKAction moveByX:y:] or update the position in the update method. This way you can control the speed of the movement exactly.

1
votes

The speed property of SKNode is to do with SKActions, however the speed property of SKPhysicsWorld is what you probably want to tweak to achieve physics in slow motion.

It says the following in the documentation about the speed property of SKPhysicsWorld

The default value is 1.0, which means the simulation runs at normal speed. A value other than the default changes the rate at which time passes in the physics simulation. For example, a speed value of 2.0 indicates that time in the physics simulation passes twice as fast as the scene’s simulation time. A value of 0.0 pauses the physics simulation.

Access it from within your SKScene subclass like this-

self.physicsWorld.speed = 0.5; // half speed (slow motion)