Reputation: 117
Hey i have a ball that gets launched in the air by an Impulse force. The ball node has gravity and etc. but What im trying to do is basically stop the impulse force that originally launched the ball in the air. I know that with Impulse its like a cannon one and done type of thing. but is there a way to just clear all forces on the node except for gravity of course? Im using scenekit in xcode and SWIFT but will take Objective C answers
Ball.physicsBody?.applyForce(velocity, impulse: true)
The line passes through any error indicators in xcode but DON'T's do anything at all unfortunately
Ball.physicsBody?.clearAllForces()
Upvotes: 0
Views: 823
Reputation: 1196
I haven't used the physics in SceneKit but I have taught Physics, maybe this will help.
Impulse and force are two different concepts. When you set impulse: true
you are stating you wish to apply an impulse INSTEAD of a force. Impulse (J) is a change in momentum and is also equal to a force applied over a set interval of time. So:
impulse = force x time
impulse = mass x change in velocity
So when you apply the impulse, you are changing your node's velocity. This would seem to me a one-time deal, effected at the time you invoke applyForce
. There should be no need to clear the impulse. (Setting impulse: false
would be another matter entirely, implying a continual force.)
Upvotes: 1